思路:

模拟,枚举。

实现:

 #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. Ubuntu 16.04安装***-qt5

    上一篇文章http://www.cnblogs.com/EasonJim/p/7133097.html中,第5步安装本地代理源服务器使用的是electron-ssr,发觉这个东西难配且难用,非常不建议 ...

  2. Visual studio 2008 的语法高亮插件 WordLight

    前段时间一直在使用matlab,今天需要使用vs2008,而用惯了matlab,习惯了其中一项选中变量高亮的设置,突然回来使用VS,感到各种不适应,顿时想到了一个词:矫情 呵呵,于是在网上找各种插件, ...

  3. [TypeScript] Define Custom Type Guard Functions in TypeScript

    One aspect of control flow based type analysis is that the TypeScript compiler narrows the type of a ...

  4. Java实现二叉搜索树及相关操作

    package com.tree; import com.tree.BitNode; /** * * 二叉搜索树:一个节点的左子节点的关键字小于这个节点.右子节点的关键字大于或等于这个父节点 * * ...

  5. 分布式数据库DDM Sidecar模式负载均衡

    简介 1.分布式数据库中间件 DDM 分布式数据库中间件(Distributed Database Middleware)是解决数据库容量.性能瓶颈和分布式扩展问题的中间件服务,提供分库分表.读写分离 ...

  6. 【bzoj4443】[Scoi2015]小凸玩矩阵

    第K大也就是第n-K+1小,所以就可以的二分答案了 (江哥讲过一道类似题) 二分答案找出比当前答案小的数的位置的坐标,判断一下是否可以选出满足不在同一行同一列的n-K+1个数,然后就可以跑匈牙利了,对 ...

  7. Windows 点击 模拟

    点击模拟  安卓模拟器  爬虫

  8. EL 隐含对象

    EL     隐含对象(11个):

  9. arm-linux交叉编译工具链的制作(基于S3C2440)【转】

    本文转载自:http://eric-gao.iteye.com/blog/2160622 制作arm-linux交叉编译工具链一般通过crosstool工具或者crosstool-NG,前者使用方便, ...

  10. 牛了个逼,phpstorm查询技巧

    两次shift,会弹出最近常用的文件. 可以查询按照方法名,类名,文件名等进行查询. Ctrl+E可以查看最近使用的文件. Ctrl+Shift+E可以查看最近修改的文件. Ctrl+shift+N ...