题目链接:http://codeforces.com/contest/845

A. Chess Tourney

水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了。

#include <bits/stdc++.h>
using namespace std;
int a[210];
int n;
int main()
{
scanf("%d", &n);
for(int i=1; i<=2*n; i++) scanf("%d", &a[i]);
sort(a+1,a+2*n+1,greater<int>());
if(a[n]!=a[n+1])
puts("YES");
else puts("NO");
return 0;
}

B. Luba And The Ticket

题意:给了一个只有6个字母的字符串,然后问最少改变几个数字,使得前3个数字的和等于后3个数字的和。

解法:直接暴力枚举这6位数字会变成什么,在满足条件下维护最小值。

#include <bits/stdc++.h>
using namespace std;
int a[10];
char s[10]; int main()
{
scanf("%s", s+1);
for(int i=1; i<=6; i++){
a[i] = s[i]-'0';
}
int ans = 100;
for(int i=0; i<10; i++){
for(int j=0; j<10; j++){
for(int k=0; k<10; k++){
for(int x=0; x<10; x++){
for(int y=0; y<10; y++){
for(int z=0; z<10; z++){
if(i+j+k==x+y+z){
int cnt = 0;
if(i!=a[1]) cnt++;
if(j!=a[2]) cnt++;
if(k!=a[3]) cnt++;
if(x!=a[4]) cnt++;
if(y!=a[5]) cnt++;
if(z!=a[6]) cnt++;
ans = min(ans, cnt);
}
}
}
}
}
}
}
printf("%d\n", ans);
}

C. Two TVs

题意:有n个电视节目,每个节目有一个开始的播放时间和结束的播放时间,现在有2台电视可以同时播放节目,但是有重合时间点的节目不能在同一台电视播放,问是否可以通过安排播放顺序让所有的节目都被播放完。

解法:一个显然的贪心,按l,r从小到大排序之后,分别往第一个和第二个电视结束时间最早的那个放就OK了。

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
struct node{
int l,r;
node(){}
bool operator<(const node &rhs) const{
if(l == rhs.l) return r<rhs.r;
return l<rhs.l;
}
}a[maxn];
int en1, en2; int main()
{
int n;
scanf("%d", &n);
for(int i=1; i<=n; i++){
scanf("%d %d", &a[i].l,&a[i].r);
}
sort(a+1,a+n+1);
en1 = -1, en2 = -1;
for(int i=1; i<=n; i++){
if(a[i].l > en1 && a[i].l > en2){
if(en1 > en2){
en2 = a[i].r;
}
else{
en1 = a[i].r;
}
}
else if(a[i].l > en1){
en1 = a[i].r;
}
else if(a[i].l > en2){
en2 = a[i].r;
}
else{
puts("NO");
return 0;
}
}
puts("YES");
return 0;
}

D. Driving Test

题意:给出n次操作,你可以忽略 可以超车,不可以超车,速度最大限制以及无速度限制这些操作,问使得超车以及改变速度合法的前提下最少需要忽略多少次操作,每次超车可以覆盖前面所有的超车和不超车,速度最大限制和无速度限制一样。

解法:直接模拟即可。

#include <bits/stdc++.h>
using namespace std; int main()
{
int n,op,x,now=0,lim=0,cnt=0;
vector<int>v;
scanf("%d", &n);
for(int i=1; i<=n; i++){
scanf("%d", &op);
if(op == 1){
scanf("%d", &x);
now=x;
while(!v.empty() && now>v.back()){
v.pop_back();
cnt++;
}
}
if(op == 2){
cnt += lim;
lim = 0;
}
if(op == 3){
scanf("%d", &x);
v.push_back(x);
while(!v.empty() && now>v.back()){
v.pop_back();
cnt++;
}
}
if(op == 4){
lim = 0;
}
if(op == 5){
v.clear();
}
if(op == 6){
lim++;
}
}
printf("%d\n", cnt);
return 0;
}

E:

F:

G. Shortest Path Problem?

题意:这道题要求从1到n的最小xor和路径,存在重边,允许经过重复点、重复边。

解法:线形基,BZOJ原题,BZOJ 2115 不过那道题求的是最大值,这个题求的是最小值。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100010;
const int maxm = 500010;
int n, m, edgecnt;
int head[maxn];
bool vis[maxn];
LL dx[maxn];
LL p[70];
LL circle[maxm], ans;
void init(){
memset(head, -1, sizeof(head));
edgecnt = 0;
}
struct edge{
int to,next;
LL w;
edge(){}
edge(int to, int next, LL w):to(to),next(next),w(w){}
}E[maxm];
int cnt = 0;
void add(int u, int v, LL w){
E[edgecnt].to = v, E[edgecnt].next = head[u], E[edgecnt].w = w, head[u] = edgecnt++;
}
void dfsloop(int x){
vis[x] = 1;
for(int i=head[x]; i+1; i=E[i].next){
int to = E[i].to;
if(!vis[to]) dx[to] = dx[x]^E[i].w, dfsloop(to);
else{
circle[++cnt] = dx[to]^dx[x]^E[i].w;
}
}
} int main()
{
int x,y;
LL z;
init();
scanf("%d %d", &n,&m);
for(int i=1; i<=m; i++){
scanf("%d %d %lld", &x,&y,&z);
add(x, y, z);
add(y, x, z);
}
dfsloop(1);
ans = dx[n];//任取一条从1到n的路径,并得到其xor和
for(int i=1; i<=cnt; i++){
for(int j=62; j>=0; j--){
if(!(circle[i]>>j)) continue;
if(!p[j]){
p[j] = circle[i];
break;
}
circle[i] ^= p[j];
}
}
//for(int i=62;i>=0;i--) if(!(ans>>i)) ans^=p[i];
//ans有初值,不能直接根据这一位是否为0来判断是否更大,max更为稳妥
for(int i=62; i>=0; i--){
if((ans^p[i])<ans){
ans = ans^p[i];
}
}
printf("%lld\n", ans);
return 0;
}

Educational Codeforces Round 27 补题的更多相关文章

  1. Educational Codeforces Round 23 补题小结

    昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> ...

  2. cordforce Educational Codeforces Round 47 补题笔记 <未完>

    题目链接 http://codeforces.com/contest/1009 A. Game Shopping 直接模拟即可,用了一个队列来存储账单 #include <iostream> ...

  3. Educational Codeforces Round 12补题 经典题 再次爆零

    发生了好多事情 再加上昨晚教育场的爆零 ..真的烦 题目链接 A题经典题 这个题我一开始推公式wa 其实一看到数据范围 就算遍历也OK 存在的问题进制错误 .. 思路不清晰 两个线段有交叉 并不是端点 ...

  4. Educational Codeforces Round 22 补题 CF 813 A-F

    A The Contest 直接粗暴贪心 略过 #include<bits/stdc++.h> using namespace std; int main() {//freopen(&qu ...

  5. Educational Codeforces Round 15 套题

    这套题最后一题不会,然后先放一下,最后一题应该是大数据结构题 A:求连续最长严格递增的的串,O(n)简单dp #include <cstdio> #include <cstdlib& ...

  6. Educational Codeforces Round 21 A-E题题解

    A题      ............太水就不说了,贴下代码 #include<string> #include<iostream> #include<cstring& ...

  7. Educational Codeforces Round 27 A B C

    A. Chess Tourney   Berland annual chess tournament is coming! Organizers have gathered 2·n chess pla ...

  8. Educational Codeforces Round 27

    期末后恢复性训练,结果完美爆炸... A,题意:2n个人,分成两队,要求无论怎么分配,第一队打赢第二队 #include<bits/stdc++.h> #define fi first # ...

  9. Educational Codeforces Round 27 F. Guards In The Storehouse

    F. Guards In The Storehouse time limit per test 1.5 seconds memory limit per test 512 megabytes inpu ...

随机推荐

  1. 封装游戏配表读取和存储(xml格式);支持行列存取,标题存取

    做服务器肯定会涉及到游戏配表,而读取游戏配表是一个必备技能; 之前一直都是采用TinyXml直接读,匹配字符串,每次加个表都是一大坨代码,看着也是心累; 因此利用了闲暇的时间封装了一个 xml配置表 ...

  2. java宠物练习

    先定一个宠物的抽象类,把所有共有的属性方法放到次类中,用于子类去继承实现. package backing2; abstract public class pet { private String n ...

  3. 深入理解 JavaScript(二)

    立即调用的函数表达式 前言 大家学 JavaScript 的时候,经常遇到自执行匿名函数的代码,今天我们主要就来想想说一下自执行. 在详细了解这个之前,我们来谈了解一下"自执行"这 ...

  4. 移动端JS事件、移动端框架

    一.移动端的操作方式和PC端是不同的,移动端主要是用手指操作,所以有特殊的touch事件,touch事件包括如下几个事件: 1.手指放到屏幕上时触发   touchstart 2.手指放在屏幕上滑动式 ...

  5. (转)AJax跨域:No 'Access-Control-Allow-Origin' header is present on the requested resource

    在本地用ajax跨域访问请求时报错: No 'Access-Control-Allow-Origin' header is present on the requested resource. Ori ...

  6. python之基本内容

    这里提供在使用python进行开发中常使用到的方法技巧,如有不对欢迎批评指正. 要点:开发中类.变量特性查询,类型就是类,断言的使用,深浅复制判断等 python脚本文件是使用UTF-8编码的,所以在 ...

  7. IDEA 单元测试testng入门及testng.xml

    直接进入正题: 1.TestNG的运行方式如下: With a testng.xml file 直接run as test suite With ant 使用ant From the command ...

  8. 【Django】request 处理流程(转)

    Django 和其他 Web 框架的 HTTP 处理的流程大致相同,Django 处理一个 Request 的过程是首先通过中间件,然后再通过默认的 URL 方式进行的.我们可以在 Middlewar ...

  9. storm从入门到放弃(三),放弃使用《StreamId》特性。

    序:StreamId是storm中实现DAG有向无环图的重要一个特性,但是从实际生产环境来看,这个功能其实蛮影响生产环境的稳定性的,我们系统在迭代时会带来整体服务的不可用. StreamId是stor ...

  10. C++基本内置类型

    C++基本内置类型 基本内置类型包括算术类型和空类型. 算术类型 算术类型包括整型和浮点型. 类型 含义 最小尺寸 bool 布尔型 - char 字符型 8 bit wchar_t 宽字符型 16 ...