Codeforces - 814B - An express train to reveries - 构造
http://codeforces.com/problemset/problem/814/B
构造题烦死人,一开始我还记录一大堆信息来构造p数列,其实因为s数列只有两项相等,也正好缺了一项,那就把两种情况构造出来暴力验证对不对就行了。
#include<bits/stdc++.h>
using namespace std;
#define ll long long int n;
int s[];
int us[];
int t[];
int ut[];
int a[]; int main(){
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&s[i]);
us[s[i]]++;
}
for(int i=;i<n;i++){
scanf("%d",&t[i]);
ut[t[i]]++;
} int t1=;
for(int i=;i<=n;i++){
if(us[i]==){
t1=i;
}
} vector<int> dif;
for(int i=;i<n;i++){
a[i]=s[i];
if(us[s[i]]==){
dif.push_back(i);
//printf("i=%d\n",i);
}
} int tmp;
for(auto i:dif){
tmp=a[i];
a[i]=t1;
int cnt=;
for(int j=;j<n;j++){
if(a[j]!=t[j])
cnt++;
}
if(cnt==){
for(int j=;j<n;j++){
printf("%d%c",a[j],(" \n"[j==n-]));
}
return ;
}
a[i]=tmp;
} }
Codeforces - 814B - An express train to reveries - 构造的更多相关文章
- codeforces 814B.An express train to reveries 解题报告
题目链接:http://codeforces.com/problemset/problem/814/B 题目意思:分别给定一个长度为 n 的不相同序列 a 和 b.这两个序列至少有 i 个位置(1 ≤ ...
- #418 Div2 Problem B An express train to reveries (构造 || 全排列序列特性)
题目链接:http://codeforces.com/contest/814/problem/B 题意 : 有一个给出两个含有 n 个数的序列 a 和 b, 这两个序列和(1~n)的其中一个全排列序列 ...
- 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 ...
- An express train to reveries
An express train to reveries time limit per test 1 second memory limit per test 256 megabytes input ...
- 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 ...
- CF814B An express train to reveries
思路: 模拟,枚举. 实现: #include <iostream> using namespace std; ; int a[N], b[N], cnt[N], n, x, y; int ...
- [Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT)
[Codeforces 553E]Kyoya and Train(期望DP+Floyd+分治FFT) 题面 给出一个\(n\)个点\(m\)条边的有向图(可能有环),走每条边需要支付一个价格\(c_i ...
- Educational Codeforces Round 7 D. Optimal Number Permutation 构造题
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...
- Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
随机推荐
- [Cypress] install, configure, and script Cypress for JavaScript web applications -- part1
Despite the fact that Cypress is an application that runs natively on your machine, you can install ...
- CSS3中transition-duration參数对hover前后两种过渡时间的影响
transition-duration这个參数是设置过渡时间的,将transition-duration放在哪个类中.那么在这个类被启用时就会依照transition-duration设定的时间来过渡 ...
- The most widely used name server software: BIND
https://www.isc.org/downloads/bind/ The most widely used name server software: BIND BIND is open sou ...
- Android - 监听Activity点击无效
监听Activity点击无效 本文地址: http://blog.csdn.net/caroline_wendy Activity须要先在Manifest注冊,才干在app中使用; Manifest: ...
- 《写给大忙人看的java》笔记--基本的编程结构
1.字符串是UTF-16编码中的Unicode编码点的序列 2.绑定System.in的Scanner可以读取终端输入: Scanner sc = new Scanner(System.in); 3. ...
- java -jar 与nohup的区别
——作为java程序员,经常会遇到这样一个问题,打个jar包,测试或者上线生产,于是乎面临的选择来了,java –jar or nohup? 下面我来扒一扒: 一. java -jar a.ja ...
- 运用Links方法安装插件
方法如下: (1)在Eclipse的安装目录下新建两个文件夹:一个用来存放插件,取名为myplugins:另一个用来存放link文件,取名为links. (2)将下载的插件解压缩到myplugins目 ...
- 百度自然语言处理api用法
def words url = "https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?access_token=1111111" param ...
- 小玩Spring Boot
Spring Boot是Spring Mvc的升级版 号称是替代者 也是微服务的微框架基础 有3启动方式 用IntelJ IDEA 生成spring boot工程 1.有个入口类 可以直接run as ...
- vue开发总结(一)
vue使用快一个多月了,从移动端到PC端,踩过的坑也不少.项目的开发是基于element ui 与 mint ui 组件库,下面总结下项目中的一些知识点: 一.网页数据请求 首次进入页面,需要请求数据 ...