又被题意坑了...

输入的一串数字的含义是第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. 看结果,测试?java中的String类 字符串拆分成字符串数组 判定邮箱地址 字符串比较 参数传递?

    看结果1? package com.swift; class ArrayString { public static void main(String[] args) { String str = & ...

  2. NOIP 2018数据点

    链接: https://pan.baidu.com/s/14jXQGPSac3b9_m5h5x2wGQ 提取码: 1cbk 好文别忘点赞!!!

  3. selenium.common.exceptions.WebDriverException: Message: u'unknown error: cannot get automation extension\nfrom unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfeb

    Python2.7 selenium3.4.1在使用chrome driver时报错:selenium.common.exceptions.WebDriverException: Message: u ...

  4. SpringBoot 多线程

    Spring通过任务执行器(TaskExecutor)来实现多线程和并发编程.使用ThreadPoolTaskExecutor可实现一个基于线程池的TaskExecutor.而实际开发中任务一般是非阻 ...

  5. angular中几种加载css的方法

    1.Style URLs in Metadata We can load styles from external CSS files by adding a styleUrls attribute ...

  6. jmeter压力测试入门

    http://www.51testing.com/html/80/n-853680.html http://blog.csdn.net/vincy_zhao/article/details/70238 ...

  7. 关于hadoop学习的思考(一) —— 小的知识点的总结

    一.对于CDH的小总结: CDH:是Cloudera公司在Apache开源项目hadoop的基础上发型的,共有五个版本前两个已不再更新,最经的两个分别是CDH4(基于hadoop2.0.0版本演化而来 ...

  8. 关于Relay Log无法自动删除的问题

    本文介绍了一次运维实践中relay-log长期无法自动删除的原因和解决过程 背景: 今天在运维一个mysql实例时,发现其数据目录下的relay-log 长期没有删除,已经堆积了几十个relay-lo ...

  9. OSPF 一 基础

    本节介绍ospf路由选择协议    为链路状态  路由选择协议 一  分类 open shortest path first   开放最短路优先   公有协议 单区域的ospf实施  运行在一个自治系 ...

  10. enable apache2 rewrite_mod on ubuntu14.04

    $ cd /etc/apache2/mods-enable $ ln -s rewrite.load ../mods-available/rewrite.load change "Allow ...