思路:

模拟,枚举。

实现:

 #include <iostream>
using namespace std; const int N = ; int a[N], b[N], cnt[N], n, x, y; int main()
{
cin >> n;
for (int i = ; i < n; i++) cin >> a[i], cnt[a[i]]++;
for (int i = ; i < n; i++) cin >> b[i];
for (int i = ; i <= n; i++)
{
if (cnt[i] == ) x = i;
else if (cnt[i] == ) y = i;
}
for (int i = ; i < n; i++)
{
if (a[i] == x)
{
a[i] = y;
int bad = ;
for (int j = ; j < n; j++)
if (b[j] != a[j]) bad++;
if (bad == )
{
for (int j = ; j < n; j++) cout << a[j] << " ";
return ;
}
a[i] = x;
}
}
return ;
}

CF814B An express train to reveries的更多相关文章

  1. An express train to reveries

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

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

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

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

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

  5. Codeforces - 814B - An express train to reveries - 构造

    http://codeforces.com/problemset/problem/814/B 构造题烦死人,一开始我还记录一大堆信息来构造p数列,其实因为s数列只有两项相等,也正好缺了一项,那就把两种 ...

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

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

  7. Codeforces Round #418 (Div. 2) A+B+C!

    终判才知道自己失了智.本场据说是chinese专场,可是请允许我吐槽一下题意! A. An abandoned sentiment from past shabi贪心手残for循环边界写错了竟然还过了 ...

  8. codeforces round 418 div2 补题 CF 814 A-E

    A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300], ...

  9. AtCoder Express(数学+二分)

    D - AtCoder Express Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement In ...

随机推荐

  1. mysql数据类型和java数据类型匹配

    Java数据类型和MySql数据类型对应一览 类型名称 显示长度 数据库类型 JAVA类型 JDBC类型索引(int) 描述             VARCHAR L+N VARCHAR java. ...

  2. Android: Mac无法找到Android SDK问题

    通过brew cask install android-sdk后,Intellij Idea中设置Android SDK路径失败,解决方法如下: /usr/local/Caskroom/android ...

  3. vue全局注册与局部注册的写法

    vue全局注册是每个实例化的vue都可以使用,而局部则是实例化注册的那个可以用.举个例子,看看写法: <div id="app"> <p>页面载入时,inp ...

  4. Wps 2013 拼音标注两种方式分析

    Wps 2013 拼音标注两种方式分析 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转 ...

  5. .net mvc4 + ajaxfileupload.js 解决IE浏览器中弹出下载对话框问题

    摘要:每一个人遇到的问题都不一样,在网上找了一大圈都没有解决到我的问题!由于我的环境如标题所看到的.攻克了这个问题. 主要问题:在于响应头的设置 Controller: [HttpPost] publ ...

  6. tf.image.resize_bilinear 图像缩放,双线性插值-图像中心对齐

    http://www.cnblogs.com/yssongest/p/5303151.html 双线性插值算法及需要注意事项 input = tf.placeholder(tf.float32, sh ...

  7. (二)Java 简介

    Java 简介 Java是由Sun Microsystems公司于1995年5月推出的Java面向对象程序设计语言和Java平台的总称.由James Gosling和同事们共同研发,并在1995年正式 ...

  8. ubuntu安装virtualbox

    1.下载 2.sudo dpkg -i virtualbox-5.2_5.2.10-122088_Ubuntu_xenial_amd64.deb $sudo dpkg -i virtualbox-5. ...

  9. MPMoviePlayerController属性方法简介

    属性 说明 @property (nonatomic, copy) NSURL *contentURL 播放媒体URL,这个URL可以是本地路径,也可以是网络路径 @property (nonatom ...

  10. win7(windows 7)系统下安装SQL2005(SQL Server 2005)图文教程( Win7 SQL Server2005 安装教程)

    win7(windows 7)系统下安装SQL2005(SQL Server 2005)图文教程 由于工作需要,今天要在电脑上安装SQL Server 2005.以往的项目都是使用Oracle,MS的 ...