思路:

模拟,枚举。

实现:

 #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. STL中常用的c++语法

    函数调用操作(c++语法中的左右小括号)可以被重载,STL的特殊版本都以仿函数形式呈现.如果对某个class进行operator()重载,它就成为一个仿函数. 仿函数(functor),就是使一个类的 ...

  2. HDD

    硬盘 SCSI ★ Host adapter ★ SCSI standard ★ Bus socket ★ Signal fashion ★ SCAM ★ Bus main control ★ Dri ...

  3. SAP ABAP 的经常使用debug方式

    SAP ABAP 的经常使用debug方式: 1. 直接在程序中设断点 在se38里面打上breakpoint,程序执行到该处即进入debug模式 2.background Job的debug 进入S ...

  4. java 数据结构. 源代码阅读

    Collections工具类里的 Collections.synchronizedList public static <T> List<T> synchronizedList ...

  5. FFmpeg的HEVC解码器源码简单分析:概述

    ===================================================== HEVC源码分析文章列表: [解码 -libavcodec HEVC 解码器] FFmpeg ...

  6. NYOJ 298-点的变换(经典矩阵解决点平移、缩放、翻转和旋转)

    题目地址:NYOJ 298 思路:该题假设用对每一个点模拟的操作.时间复杂度为O(n+m),结果肯定超时.然而利用矩阵乘法能够在O(m)的时间内把全部的操作合并为一个矩阵,然后每一个点与该矩阵相乘能够 ...

  7. web 开发之js---js 实现地址栏的表单提交加密编码

    以前在做嵌入式web时,曾经想过cgi加密,原来js可以直接实现,太好了,这里js在客户端实现编码和解码 一.在地址栏直接输入:javascript:str=encodeURI("笃行天下& ...

  8. ASP.NET MVC Model之二模型绑定

    Asp.net mvc中的模型绑定,或许大家经常用,但是具体说他是怎么一回事,可能还是会有些陌生,那么,本文就带你理解模型绑定.为了理解模型绑定,本文会先给出其定义,然后对通过比,来得出使用模型绑定的 ...

  9. 获取浏览器弹窗alert、自定义弹窗以及其操作

    web自动化测试第10步:获取浏览器弹窗alert.自定义弹窗以及其操作 - CSDN博客 http://blog.csdn.net/ccggaag/article/details/76573857 ...

  10. 音乐播放器之myeclipse项目

    音乐播放器: 这个音乐播放器是用myeclipse打开的项目.假设有问题记得改掉文件的路径名.还有假设图片不显示也可能是图片的路径名不正确,如音乐无法播放也可能是路径名不正确.总之这个游戏有文件的引用 ...