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 - 构造的更多相关文章

  1. codeforces 814B.An express train to reveries 解题报告

    题目链接:http://codeforces.com/problemset/problem/814/B 题目意思:分别给定一个长度为 n 的不相同序列 a 和 b.这两个序列至少有 i 个位置(1 ≤ ...

  2. #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)

    题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...

  3. 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 ...

  4. An express train to reveries

    An express train to reveries time limit per test 1 second memory limit per test 256 megabytes input  ...

  5. 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 ...

  6. CF814B An express train to reveries

    思路: 模拟,枚举. 实现: #include <iostream> using namespace std; ; int a[N], b[N], cnt[N], n, x, y; int ...

  7. [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT)

    [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT) 题面 给出一个\(n\)个点\(m\)条边的有向图(可能有环),走每条边需要支付一个价格\(c_i ...

  8. Educational Codeforces Round 7 D. Optimal Number Permutation 构造题

    D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...

  9. Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉

    Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

随机推荐

  1. 转: 在CentOS 6.X 上面安装 Python 2.7.X

    转:https://ruiaylin.github.io/2014/12/12/python%20update/ 评注: yum -y update //这个更新太坑了,1120更新包...想死的心都 ...

  2. centos 7 -- Disk Requirements: At least 134MB more space needed on the / filesystem.

    用了幾年的centos7,今天執行yum update時,彈出一行有錯誤的提示:Disk Requirements:   At least 134MB more space needed on the ...

  3. Android6.0权限管理以及使用权限该注意的地方

    Android 6.0 Marshmallow首次增加了执行时权限管理,这对用户来说,能够更好的了解.控 制 app 涉及到的权限.然而对开发人员来说却是一件比較蛋疼的事情.须要兼容适配,并保证程序功 ...

  4. 有关不同浏览器不同版本号的css以及js计算高度的问题

    1.input在全部浏览器以及全部的版本号中,都是定义了高度.然后再定义padding或者border值.这时候都会撑开.高度是本身的高度在padding值和border值 2.select在gool ...

  5. mysql 安装与启动

    1.下载mysql installer 2.安装 一直点next,直到finish. 3.安装时的配置 安装完后,选择立即开始配置. 选择standard configuration 勾选安装mysq ...

  6. Spring Boot 使用Java代码创建Bean并注冊到Spring中

    从 Spring3.0 開始,添加了一种新的途经来配置Bean Definition,这就是通过 Java Code 配置 Bean Definition. 与Xml和Annotation两种配置方式 ...

  7. C++写动态站点之HelloWorld!

    演示样例源码下载地址:Fetch_Platform.7z 更复杂的代码可參考本博客BBS的实现 简单的说.动态站点就是能够动态变更的站点.动态变化的内容通常来自后端数据库.例如以下省略万字(动态站点) ...

  8. sphinx的配置和管理

    网上配置文档众多,但是对着他们的文档来做老是出问题,于是花了点时间研究了一下,写成总结,方便以后查阅.也希望学习sphinx的朋友能少走弯路.Coreseek的安装请参考:http://blog.ch ...

  9. 不是技术牛人,如何拿到国内IT巨头的Offer--转

    http://blog.csdn.net/lsldd/article/details/13506263 不久前,byvoid面阿里星计划的面试结果截图泄漏,引起无数IT屌丝的羡慕敬仰.看看这些牛人,N ...

  10. 手游服务器php架构比较

    从swoole项目开始到现在,一直有人在问这个问题.今天来抽空讲一下它.为什么swoole非要使用纯C来写而不是PHP代码来实现,核心的原因有2点: 1. PHP无法直接调用操作系统API 如send ...