终于有场正常时间的比赛了。。。毛子换冬令时还正是好啊233

做了ABCD,E WA了3次最后没搞定,F不会= =

那就来说说做的题目吧= =

A. Team Olympiad

水题嘛= =

就是个贪心什么的乱搞,貌似放A题难了

 #include <cstdio>
#include <algorithm> using namespace std;
const int N = ; int cnt[], first[], next[N]; int main() {
int n ,i, x, ans;
int a, b, c;
scanf("%d", &n);
for (i = ; i <= n; ++i) {
scanf("%d", &x);
next[i] = first[x], first[x] = i;
++cnt[x];
}
ans = min(min(cnt[], cnt[]), cnt[]);
printf("%d\n", ans);
a = first[], b = first[], c = first[];
for (i = ; i <= ans; ++i) {
printf("%d %d %d\n", a, b, c);
a = next[a], b = next[b], c = next[c];
}
}

B. Queue

这放B题真的合适吗= =

就是模拟啦,但是但是,具体处理好麻烦的说!!!

 #include <cstdio>
#include <algorithm> using namespace std;
const int N = (int) 1e6 + ;
int S = (int) 1e6 + ;
int T = (int) 1e6 + ; struct edges {
int next, to;
edges() {}
edges(int _next, int _to) : next(_next), to(_to) {}
}e[N << ]; int n, tot, first[N];
int ans[N], cnt;
int Cnt[N];
bool v[N]; inline void add_edges(int x, int y){
e[++tot] = edges(first[x], y), first[x] = tot;
e[++tot] = edges(first[y], x), first[y] = tot;
} int main() {
int i, x, y;
scanf("%d", &n);
for (i = ; i <= n; ++i) {
scanf("%d%d", &x, &y);
++Cnt[x], --Cnt[y];
if (x == ) x = S;
if (y == ) y = T;
add_edges(x, y);
}
v[S] = , cnt = ;
while () {
for (x = first[S]; x; x = e[x].next)
if (!v[e[x].to]) break;
if (x == ) break;
v[S = e[x].to] = ;
ans[cnt << ] = S, ++cnt;
}
if (n & == ) {
v[T] = , cnt = ;
while () {
for (x = first[T]; x; x = e[x].next)
if (!v[e[x].to]) break;
if (x == ) break;
v[T = e[x].to] = ;
ans[n + - (cnt << )] = T, ++cnt;
}
} else {
for (i = ; i <= N; ++i)
if (Cnt[i] == ) {
S = i;
break;
}
ans[] = S;
v[S] = , cnt = ;
while () {
for (x = first[S]; x; x = e[x].next)
if (!v[e[x].to]) break;
if (x == ) break;
v[S = e[x].to] = ;
ans[cnt << | ] = S, ++cnt;
}
}
for (i = ; i < n; ++i)
printf("%d ", ans[i]);
printf("%d\n", ans[n]);
return ;
}

C. Hacking Cypher

正这反着扫两遍,直接判断就好了,报noip高精模写错的一箭之仇!

 #include <cstdio>
#include <cstring>
#include <algorithm> using namespace std;
typedef long long ll;
const int N = (int) 1e6 + ; ll a, b;
int len;
bool ok_a[N], ok_b[N];
char st[N]; int main() {
ll tmp, T;
int i, j;
scanf("%s", st + ); len = strlen(st + );
scanf("%I64d%I64d", &a, &b);
tmp = ;
for (i = ; i <= len; ++i) {
((tmp *= ) += st[i] - '' ) %= a;
if (tmp == ) ok_a[i] = ; else ok_a[i] = ;
}
tmp = , T = ;
for (i = len; i; --i) {
(tmp += (ll) T * (st[i] - '')) %= b;
(T *= ) %= b;
if (tmp == ) ok_b[i] = ; else ok_b[i] = ;
}
for (i = ; i <= len; ++i)
if (ok_a[i - ] && ok_b[i] && st[i] != '') break;
if (i == len + ) {
puts("NO");
return ;
}
puts("YES");
for (j = ; j < i; ++j)
putchar(st[j]); puts("");
for (j = i; j <= len; ++j)
putchar(st[j]); puts("");
return ;
}

D. Chocolate

第一眼神题Orz

后来发现,是指1 * 1的方格一样多。。。这尼玛是在逗我!

于是计算面积s1, s2,令s1 /= gcd, s2 /= gcd

然后判断s1 * (2 / 3) ^ x1 * (1 / 2) ^ y1 = s2 * (2 / 3) ^ x2 * (1 / 2) ^ y2 是否有非负整数解(x1, x2, y1, y2)且x1, x2; y1, y2中都至少有一个0

乱搞吧2333

 #include <cstdio>

 using namespace std;
typedef long long ll; ll a, b, c, d, s1, s2, G;
int ans;
int cnt[][]; ll gcd(ll a, ll b) {
return !b ? a : gcd(b, a % b);
} int abs(int x) {
return x < ? -x : x;
} void work() {
ans += cnt[][] + cnt[][] + abs(cnt[][] + cnt[][] - cnt[][] - cnt[][]);
} int main() {
scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);
s1 = a * b;
s2 = c * d;
G = gcd(s1, s2);
s1 /= G, s2 /= G;
while (!(s1 & )) s1 >>= , ++cnt[][];
while (s1 % == ) s1 /= , ++cnt[][];
while (!(s2 & )) s2 >>= , ++cnt[][];
while (s2 % == ) s2 /= , ++cnt[][];
if (s1 > || s2 > ) {
puts("-1");
return ;
}
work();
printf("%d\n", ans);
cnt[][] += cnt[][], cnt[][] += cnt[][];
if (cnt[][] > cnt[][]) cnt[][] -= cnt[][], cnt[][] = ;
else cnt[][] -= cnt[][], cnt[][] = ;
while (cnt[][]--) {
if (a % == ) (a /= ) *= ;
else (b /= ) *= ;
}
while (cnt[][]--) {
if (c % == ) (c /= ) *= ;
else (d /= ) *= ;
}
while (cnt[][]--) {
if (!(a & )) a /= ;
else b /= ;
}
while (cnt[][]--) {
if (!(c & )) c /= ;
else d /= ;
}
printf("%I64d %I64d\n%I64d %I64d\n", a, b, c, d);
return ;
}

E. Restoring Increasing Sequence

字符串处理一下,然后贪心当前最小即可,然后我的bin数组少了个0,WA到死啊!!!

我的Div.2 Rank 10-快还我。。。呜呜呜

 #include <cstdio>
#include <cstring> using namespace std;
const int bin[] = {, , , , , , , , };
const int N = ; int n, len, len_last;
char st[];
int ans[N]; int work(int p) {
int res = , i, j;
if (len_last > len) return ;
if (len_last < len) {
for (i = ; i <= len; ++i)
if (st[i] == '?')
if (i == ) res = ; else res *= ;
else (res *= ) += st[i] - '';
return res;
}
for (i = ; i <= len; ++i)
if (st[i] == '?')
(res *= ) += ;
else (res *= ) += st[i] - '';
if (res <= ans[p - ]) return ;
for (i = ; i <= len; ++i)
if (st[i] == '?')
for (j = ; j <= ; ++j)
if (res - bin[len - i] <= ans[p - ]) break;
else res -= bin[len - i];
return res; } int main() {
int i;
scanf("%d\n", &n);
ans[] = ;
len = ;
for (i = ; i <= n; ++i) {
scanf("%s\n", st + );
len_last = len, len = strlen(st + );
if (!(ans[i] = work(i))) {
puts("NO");
return ;
}
}
puts("YES");
for (i = ; i <= n; ++i)
printf("%d\n", ans[i]);
return ;
}

F. Treeland Tour

第一反应是树上DP,每个点一个平衡树维护。。。

后来发现怎么可能,应该是点分治 + 归并数组。。。

但是真的能写的出来?不明= =(话说至今No Tags,什么东西!)

反正Div.2里只有一个人A了F,但是Div.1里A掉的貌似很多啊?以后再说吧

于是蒟蒻喜闻乐见的Div.2 Rank 44,被各位神犇D飞啦~Orz跪

话说,蒟蒻的Rating曲线越来越了难看了233

Codeforces Round #279 (Div. 2) 题解集合的更多相关文章

  1. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  2. Codeforces Round #182 (Div. 1)题解【ABCD】

    Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...

  3. Codeforces Round #608 (Div. 2) 题解

    目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...

  4. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  5. Codeforces Round #528 (Div. 2)题解

    Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...

  6. Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F

    Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...

  7. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

  8. Codeforces Round #665 (Div. 2) 题解

    Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...

  9. Codeforces Round #533 (Div. 2)题解

    link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...

随机推荐

  1. Rain on your Parade---hdu2389(HK求最大匹配)

    题目链接 题意:有n个客人,m把雨伞,在t秒之后将会下雨,给出每个客人的坐标和每秒行走的距离,以及雨伞的位置,问t秒后最多有几个客人可以拿到雨伞? 就是求最大匹配的  Hopcroft-Karp复杂度 ...

  2. Python开发【Django】:CMDB基础

    浅谈ITIL TIL即IT基础架构库(Information Technology Infrastructure Library, ITIL,信息技术基础架构库)由英国政府部门CCTA(Central ...

  3. Day04 dom详解及js事件

    day04 dom详解 DOM的基础 Document对象 Element对象 Node对象 innerHTML 事件处理 表单验证   上次课内容回顾: JS中ECMAScript用法: JS定义变 ...

  4. CCScene,CCLayer,CCSprite,CCDirector

    一.CCScene : 游戏中不同的画面可以用不同的场景展示出来,大致的可以分为以下的几类场景: 1. 展示类场景.游戏开场画面,游戏简介,胜利以及失败提示,帮助. 2. 选择类场景.主菜单,游戏设置 ...

  5. XShell已经内置rz 直接从Windows拖文件进去终端

    XShell已经内置rz 直接从Windows拖文件进去终端 http://www.jb51.net/LINUXjishu/163820.html 借助securtCRT,使用linux命令sz可以很 ...

  6. orcle中如何使用动态游标来对变量进行赋值

    在oracle中动态游标的概念一般不常用,但有时根据客户的特殊业务,需要使用到动态游标来解决问题!在对于一条动态SQL语句而产生多条记录时,动态游标的使用将是一个很好的选择,具体参见如下在工作流项目中 ...

  7. [RGEOS]空间拓扑关系

    -1.判断两个线段是否平行 inline bool parallel_seg_seg(Segment_2 S1, Segment_2 S2) { Vector_2 u(S1); Vector_2 v( ...

  8. OPENSSL编程 (secure shell, ssh)

    很好的 OPENSSL编程 教程,名字就叫“OPENSSL编程” 它里面还有很多关于密码学的东西. http://www.pengshuo.me http://www.pengshuo.me/2014 ...

  9. 开启Virtualization Technology

    怎样开启Virtualization Technology功能 在Win7 或linux x64位系统里装vm,然后新建虚机安装Windows Server 2008 R2 提示一些警告,无法新建虚拟 ...

  10. DHCP服务器配置实践

    实验背景:在LINUX系统上为一园区网络配置DHCP服务器,给网络内各主机自动分配IP地址,地址池范围为:192.168.X.100~192.168.X.200,配置作用域选项,其中网关为:192.1 ...