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 ...
随机推荐
- 苹果Macbook Air怎么安装Win7系统图解教程
下面开始我们在苹果Macbook Air上的Windows7之旅吧.
- 2014-8-21的一次性能诊断--应用server瓶颈
今天现场实施反馈系统总体慢.已经接到用户许多的投诉,要求现场发回weblogic日志和Oracle 数据库报告.简要说下系统的架构:典型的B/S三层架构,开发语言是java,中间件用的是weblogi ...
- 异 形 卵 709 南阳oj
http://acm.nyist.net/JudgeOnline/problem.php? pid=709 异 形 卵 时间限制:1000 ms | 内存限制:65535 KB 难度: 描写叙述 ...
- CSS 全部的列表样式类型
<html> <head> <style type="text/css"> ul.none {list-style-type: none} ul ...
- 贪吃蛇 c++ ncurses
近期学ncurses.用贪吃蛇训练下 思路:不构造链表.蛇头向前进方向打点,蛇尾逐点消失,形成移动. 须要记录蛇头方向,蛇尾方向.并用list仿造队列,增加拐点信息(空间比链表每一个结点开辟空间节省非 ...
- CentOS+Apache+php无法访问redis的解决方法 Redis server went away
在CentOS下配置Apache+php+redis+phpredis环境.编辑访问redis缓存的php程序test.php,以应用程序方式在后台运行,可成功访问Redis,而在Apache下以网页 ...
- Velocity高速新手教程
变量 (1)变量的定义: #set($name = "hello") 说明:velocity中变量是弱类型的. 当使用#set 指令时,括在双引號中的字面字符串将解析和又 ...
- VirtualMachineManager
Java Code Examples for com.sun.jdi.VirtualMachineManager https://www.programcreek.com/java-api-examp ...
- WEB安全实战(四)关于 Cookie
前言 这几天中,一直再跟漏洞打交道,而在这些漏洞中,出现的最多的就是 Cookie 和 Session 了.这篇文章就简单的介绍一些 Cookie 中最经常使用的四个属性.也算是为兴许的文章做一个铺垫 ...
- HTTPS数据包抓取的可行性分析
HTTPS数据包抓取的可行性分析 相信只要是从事软件开发, 多多少少都会涉及到数据包的抓取.常见的有网页数据抓取(即网页爬虫),应用程序数据包抓取等.网页数据抓取比较简单, 在chrome下可以非常方 ...