Codeforces - 814B - An express train to reveries - 构造
http://codeforces.com/problemset/problem/814/B
构造题烦死人,一开始我还记录一大堆信息来构造p数列,其实因为s数列只有两项相等,也正好缺了一项,那就把两种情况构造出来暴力验证对不对就行了。
#include<bits/stdc++.h>
using namespace std;
#define ll long long int n;
int s[];
int us[];
int t[];
int ut[];
int a[]; int main(){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&s[i]);
us[s[i]]++;
}
for(int i=;i<n;i++){
scanf("%d",&t[i]);
ut[t[i]]++;
} int t1=;
for(int i=;i<=n;i++){
if(us[i]==){
t1=i;
}
} vector<int> dif;
for(int i=;i<n;i++){
a[i]=s[i];
if(us[s[i]]==){
dif.push_back(i);
//printf("i=%d\n",i);
}
} int tmp;
for(auto i:dif){
tmp=a[i];
a[i]=t1;
int cnt=;
for(int j=;j<n;j++){
if(a[j]!=t[j])
cnt++;
}
if(cnt==){
for(int j=;j<n;j++){
printf("%d%c",a[j],(" \n"[j==n-]));
}
return ;
}
a[i]=tmp;
} }
Codeforces - 814B - An express train to reveries - 构造的更多相关文章
- codeforces 814B.An express train to reveries 解题报告
题目链接:http://codeforces.com/problemset/problem/814/B 题目意思:分别给定一个长度为 n 的不相同序列 a 和 b.这两个序列至少有 i 个位置(1 ≤ ...
- #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)
题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...
- B. An express train to reveries
B. An express train to reveries time limit per test 1 second memory limit per test 256 megabytes inp ...
- An express train to reveries
An express train to reveries time limit per test 1 second memory limit per test 256 megabytes input ...
- Codeforces Round #418 (Div. 2) B. An express train to reveries
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- CF814B An express train to reveries
思路: 模拟,枚举. 实现: #include <iostream> using namespace std; ; int a[N], b[N], cnt[N], n, x, y; int ...
- [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT)
[Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT) 题面 给出一个\(n\)个点\(m\)条边的有向图(可能有环),走每条边需要支付一个价格\(c_i ...
- Educational Codeforces Round 7 D. Optimal Number Permutation 构造题
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...
- Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
随机推荐
- ubutu强制结束进程 kill -9 ProcessID
强制终止进程 kill -9 2128 表示强制结束进程号 2128 对应的进程.
- oracle下session的查询与删除
oracle下session的查询与删除 1.查询当前session SQL> select username,sid,serial# from v$session where username ...
- go test test & benchmark
开发程序其中很重要的一点是测试,我们如何保证代码的质量,如何保证每个函数是可运行,运行结果是正确的,又如何保证写出来的代码性能是好的,我们知道单元测试的重点在于发现程序设计或实现的逻辑错误,使问题及早 ...
- eclipse中progress一直在刷新问题处理
- C#语言循环语句for嵌套
- C++模板实现的AVL树
1 AVL树的定义 AVL树是一种自平衡二叉排序树.它的特点是不论什么一个节点的左子树高度和右子树的高度差在-1,0,1三者之间. AVL树的不论什么一个子树都是AVL树. 2 AVL树的实现 AVL ...
- poj2406--Power Strings(kmp:求循环串的次数)
Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 33163 Accepted: 13784 D ...
- 修改flash builder注释里的@author
在flash builder里,按Ctrl+Shift+D可以很方便在添加AsDoc注释.可是有些生成的@author是系统的用户名(如:administor),怎么修改这个为自己的名字呢? Step ...
- JOIN ,LEFT JOIN ,ALL JOIN 等的区别和联系
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录 inner join(等值连接) ...
- js对table操作(添加删除交换上下TR)
<table width="100%" border="0" cellpadding="2" cellspacing="1& ...