CF814B An express train to reveries
思路:
模拟,枚举。
实现:
#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的更多相关文章
- An express train to reveries
An express train to reveries time limit per test 1 second memory limit per test 256 megabytes input ...
- 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 ...
- 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 ...
- codeforces 814B.An express train to reveries 解题报告
题目链接:http://codeforces.com/problemset/problem/814/B 题目意思:分别给定一个长度为 n 的不相同序列 a 和 b.这两个序列至少有 i 个位置(1 ≤ ...
- Codeforces - 814B - An express train to reveries - 构造
http://codeforces.com/problemset/problem/814/B 构造题烦死人,一开始我还记录一大堆信息来构造p数列,其实因为s数列只有两项相等,也正好缺了一项,那就把两种 ...
- #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)
题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...
- Codeforces Round #418 (Div. 2) A+B+C!
终判才知道自己失了智.本场据说是chinese专场,可是请允许我吐槽一下题意! A. An abandoned sentiment from past shabi贪心手残for循环边界写错了竟然还过了 ...
- codeforces round 418 div2 补题 CF 814 A-E
A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300], ...
- AtCoder Express(数学+二分)
D - AtCoder Express Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement In ...
随机推荐
- 英特尔固态盘 说明书PDF
http://www.intel.cn/content/www/cn/zh/solid-state-drives/solid-state-drives-ssd.html
- eclipse bug之No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK
解决办法: 1.eclipse菜单 - Window - Preferences- Java - Installed JREs 将配置的JRE定位到JDK,例如JRE home:D:\Program ...
- Redux 中文文档
http://cn.redux.js.org/docs/introduction/Ecosystem.html
- 笔记本电脑 联想 Thinkpad E420 无法打开摄像头怎么办
1 计算机管理-右击USB视频设备(应该显示为黄色问号,表示驱动安装不成功),点击浏览计算机以查找驱动程序软件 2 选择"从计算机的设备驱动程序列表中选择",然后选择Microso ...
- 我是怎样自学 Android 的?
1. Java知识储备 本知识点不做重点解说: 对于有基础的同学推荐看<Java编程思想>,巩固基础,查漏补全,了解并熟悉很多其它细节知识点. 对于没有基础的同学推荐看一本Java基础的书 ...
- ZOJ 1806 (小数高精度)
题意:八进制小数转化成十进制的小数. 0.d1d2d3 ... dk [8] = 0.D1D2D3 ... Dm [10] 例: 0.75 [8] = 7*8^-1+5*8^-2 = ( 5/8 + ...
- 20160225.CCPP体系具体解释(0035天)
程序片段(01):CircleList.h+CircleList.c+main.c 内容概要:环形链表 ///CircleList.h #pragma once #include <stdio. ...
- Apple Swift学习教程
翻译自苹果的官方文档:The Swift Programming Language. 简单介绍 今天凌晨Apple刚刚公布了Swift编程语言,本文从其公布的书籍<The Swift Progr ...
- c# Winform实现中国省份地图
1.利用raphael.js IE下的VML和SVG实现矢量地图 2.JS调用c# Winform代码,代码 [System.Runtime.InteropServices.ComVisibleAtt ...
- JavaScript基础 -- 常见DOM树操作
1.创建并增加元素节点 <ul id="ul"> <li>1</li> <li>2</li> <li>3&l ...