又被题意坑了...

输入的一串数字的含义是第i个数字是第a[i]个发生的。而不是编号为i的历史事件的实际发生顺序。所以第一步要做的是转换,将原始数据转换成编号为i的历史事件的实际发生顺序。然后按照实际的发生顺序在aaa数组中给予权值,这是为了方便之后判断学生的答案中两个数字的相对顺序。

#include<stdio.h>
#include<string.h>
int aa[];//存储初步转换完成后的标准事件顺序
int aaa[];//存储标准事件顺序的权值,方便以后比较两个数的相对大小
int ttmp[];//存储转换完成后的考生答案
int dp[];//记录第i个数之前最长的字串
int main()
{
int a,tmp,maxx;
int i,j;
scanf("%d",&a);
for(i=;i<=a;i++)
{
scanf("%d",&tmp);
aa[tmp]=i;
}
for(i=;i<=a;i++)
{
aaa[aa[i]]=i;
}
while(scanf("%d",&tmp)!=EOF)
{
ttmp[tmp]=;
for(i=;i<=a;i++)
{
dp[i]=;
}
for(i=;i<=a;i++)
{
scanf("%d",&tmp);
ttmp[tmp]=i;
}
for(i=;i<=a;i++)
{
maxx=;
for(j=i;j>=;j--)
{
if(aaa[ttmp[i]]>aaa[ttmp[j]]&&maxx<dp[j])
{
maxx=dp[j];
if(dp[j]>=j)
break;
}
}
dp[i]+=maxx;
}
maxx=;
for(i=;i<=a;i++)
{
if(maxx<dp[i])
maxx=dp[i];
}
printf("%d\n",maxx);
}
return ;
}

UVA 111的更多相关文章

  1. uva 111 History Grading(最长公共子序列)

    题目连接:111 - History Grading 题目大意:给出一个n 代表序列中元素的个数, 然后是一个答案, 接下来是若干个同学的答案(直到文件结束为止), 求出两个序列的最长公共子序列, 注 ...

  2. UVA 111 History Grading

    读题读了好久,其实就是在输入数据时要对数据的位置进行相应的改变 #include<iostream> #include<cstring> #include<cstdio& ...

  3. UVa 111 - History Grading (by 最长公共子序列 )

     History Grading  Background Many problems in Computer Science involve maximizing some measure accor ...

  4. uva 111 - History Grading (dp, LCS)

    题目链接 题意:给N,第二行是答案,n个数c1---cn, 代表第一个的顺序是c1,第二个数顺序是c2; 下面每一行是学生的答案,格式同上. 注意:这个给的顺序需要处理一下,不能直接用. 思路:LCS ...

  5. UVa 111 History Grading (简单DP,LIS或LCS)

    题意:题意就是坑,看不大懂么,结果就做不对,如果看懂了就so easy了,给定n个事件,注意的是, 它给的是第i个事件发生在第多少位,并不是像我们想的,第i位是哪个事件,举个例子吧,4 2 3 1, ...

  6. UVA 111(LCS问题)

     History Grading  Background Many problems in Computer Science involve maximizing some measure accor ...

  7. UVA 111 (复习dp, 14.07.09)

     History Grading  Background Many problems in Computer Science involve maximizing some measure accor ...

  8. uva 111 History Grading(lcs)

    题目描述 在信息科学中有一些是关于在某些条件限制下,找出一些计算的最大值. 以历史考试来说好了,学生被要求对一些历史事件根据其发生的年代顺序来排列.所有事件顺序都正确的学生无疑的可以得满分.但是那些没 ...

  9. UVA 111 简单DP 但是有坑

    题目传送门:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18201 其实是一道不算难的DP,但是搞了好久,才发现原来是题目没 ...

随机推荐

  1. C# 队列Queue

    using System; using System.Collections.Generic; using System.Linq; namespace Queue测试 { class Program ...

  2. Bootstrap 网页乱码

    问题:今天早上在实践bootstrap的时候,用EditPlus写代码,标签中包含了中文.在浏览器解析的时候中文部分生成的乱码.但是网页部分已经声明了使用utf-8的编码方式. 解决:网页字体正常显示 ...

  3. 配置SpringMVC返回JSON遇到的坑

    坑一:官方网站下载地址不明朗,最后找了几个下载地址:http://wiki.fasterxml.com/JacksonDownload Jackson2.5下载地址:jackson2.5.0.jar ...

  4. ios之alloc和init

      复制代码 SomeObject *obj = [[SomeObject alloc] initWithCenter:centerPoint radius:radius]; 和   复制代码 Som ...

  5. Instance Methods are Curried Functions in Swift

    An instance method in Swift is just a type method that takes the instance as an argument and returns ...

  6. Git学习——创建与合并分支

    分支概念 当前我们所在的分支是master(主分支),可以通过创建分支: git branch <branch_name> 创建完成后,可以查看当前的分支状态: git branch 当前 ...

  7. python:mysql增量备份

    模块:MySQLdb Crypto加密 ConfigParser加载配置 mydb.py #!/usr/bin/env python #coding=utf-8 import MySQLdb as m ...

  8. getComputedStyle与currentStyle获取元素当前的css样式

    CSS的样式分为三类: 内嵌样式:是写在标签里面的,内嵌样式只对所在的标签有效内部样式:是写在HTML里面的,内部样式只对所在的网页有效外部样式表:如果很多网页需要用到同样的样式,将样式写在一个以.c ...

  9. css3-flex-box(2)

    使用方法 使用Flexbox布局只要在父容器元素上设置display属性: .flex-container { display: -webkit-flex; /* Safari */ display: ...

  10. python--subprocess,粘包现象与解决办法,缓冲区

    一. subprocess 的简单用法 import subprocess sub_obj = subprocess.Popen( 'dir', #系统指令 shell=True, #固定方法 std ...