UVA 111 History Grading
读题读了好久,其实就是在输入数据时要对数据的位置进行相应的改变
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int order[], arr[], d[][]; int main()
{
int n, t;
scanf("%d",&n);
// 读入正确的答案顺序
for(int i=; i<n; ++i)
{
scanf("%d",&t);
order[t-]=i+; //放入他排名的位置
}
while(~scanf("%d",&t))
{
arr[t-]=;
for(int i=; i<n; ++i)
{
scanf("%d",&t);
arr[t-]=i+;
}
// 求出最长公共子序列长度
memset(d, , sizeof(d));
for(int i=; i<=n; ++i)
{
for(int j=; j<=n; ++j)
{
if(order[i-]==arr[j-])
d[i][j]=d[i-][j-]+;
else
d[i][j]=max(d[i-][j],d[i][j-]);
}
}
printf("%d\n", d[n][n]);
}
return ;
}
UVA 111 History Grading的更多相关文章
- uva 111 History Grading(最长公共子序列)
题目连接:111 - History Grading 题目大意:给出一个n 代表序列中元素的个数, 然后是一个答案, 接下来是若干个同学的答案(直到文件结束为止), 求出两个序列的最长公共子序列, 注 ...
- UVa 111 - History Grading (by 最长公共子序列 )
History Grading Background Many problems in Computer Science involve maximizing some measure accor ...
- uva 111 - History Grading (dp, LCS)
题目链接 题意:给N,第二行是答案,n个数c1---cn, 代表第一个的顺序是c1,第二个数顺序是c2; 下面每一行是学生的答案,格式同上. 注意:这个给的顺序需要处理一下,不能直接用. 思路:LCS ...
- UVa 111 History Grading (简单DP,LIS或LCS)
题意:题意就是坑,看不大懂么,结果就做不对,如果看懂了就so easy了,给定n个事件,注意的是, 它给的是第i个事件发生在第多少位,并不是像我们想的,第i位是哪个事件,举个例子吧,4 2 3 1, ...
- uva 111 History Grading(lcs)
题目描述 在信息科学中有一些是关于在某些条件限制下,找出一些计算的最大值. 以历史考试来说好了,学生被要求对一些历史事件根据其发生的年代顺序来排列.所有事件顺序都正确的学生无疑的可以得满分.但是那些没 ...
- UVA 111(LCS问题)
History Grading Background Many problems in Computer Science involve maximizing some measure accor ...
- UVA 111 (复习dp, 14.07.09)
History Grading Background Many problems in Computer Science involve maximizing some measure accor ...
- History Grading
uva111:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24& ...
- [uva] 1671 History of Languages
题目描述 输入两个DFA,判断是否等价. https://uva.onlinejudge.org/external/16/1671.pdf 输入 第一行T 可以接受的字母表 第二行N 状态数 接下去N ...
随机推荐
- mongodb安装 window
安装MongoDB 1.按照操作系统下载http://www.mongodb.org/downloads. 2.在D盘新建MongoDB文件夹(此文件夹为自定义的数据库安装目录D:\MongoDB)把 ...
- leetcode 173. Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the ro ...
- CSS3中动画属性transform、transition和animation
Transform:变形 在网页设计中,CSS被习惯性的理解为擅长表现静态样式,动态的元素必须借助于javascript才可以实现,而CSS3的出现改变了这一思维方式.CSS3除了增加革命性的创新功能 ...
- 对C++虚函数、虚函数表的简单理解
一.虚函数的作用 以一个通用的图形类来了解虚函数的定义,代码如下: #include "stdafx.h" #include <iostream> using name ...
- 项目:BluetoothChat
代码在github: https://github.com/Viyu/BluetoothChat 蓝牙聊天核心是Android Demo里的,我加上了类似微信的界面. 我觉得这个应用要是能推广的话,有 ...
- ubuntu15.10下编译安装wine1.8 rc4
ubuntu15.10下编译安装wine1.8rc4 Wine (“Wine Is Not an Emulator” 的递归缩写)是一个能够在多种 POSIX-compliant 操作系统(诸如 Li ...
- 五步搞定Android开发环境部署——非常详细的Android开发环境搭建教程
在windows安装Android的开发环境不简单也说不上算复杂,本文写给第一次想在自己Windows上建立Android开发环境投入Android浪潮的朋友们,为了确保大家能顺利完成开发环境的搭 ...
- 全局对象的构造函数会在main 函数之前执行
#include <iostream> using namespace std; class A { public: A() { cout << "Generator ...
- POJ 2051
http://poj.org/problem?id=2051 这个题目的大题意思就是给你一些ID,和ID所对应的周期,每隔它所对应的周期,它的任务就会执行,就会输出所对应的ID Register 20 ...
- pypi 国内镜像 及修改全局方法
PyPi的官方网站为https://pypi.python.org,有时访问中会很慢,使用pip命令安装带其他依赖包的安装包,会经常失败.解决办法,使用国内PyPi镜像网站,修改pip的源. 网上搜索 ...