Codeforces Round #279 (Div. 2) 题解集合
终于有场正常时间的比赛了。。。毛子换冬令时还正是好啊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) 题解集合的更多相关文章
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #182 (Div. 1)题解【ABCD】
Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...
- Codeforces Round #608 (Div. 2) 题解
目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...
- Codeforces Round #525 (Div. 2)题解
Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...
- Codeforces Round #528 (Div. 2)题解
Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...
- Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F
Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...
- Codeforces Round #677 (Div. 3) 题解
Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...
- Codeforces Round #665 (Div. 2) 题解
Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...
- Codeforces Round #533 (Div. 2)题解
link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...
随机推荐
- SLF4J其实只是一个门面服务而已,他并不是真正的日志框架,真正的日志的输出相关的实现还是要依赖Log4j、logback等日志框架的。
小结: 1.加层: 每一种日志框架都有自己单独的API,要使用对应的框架就要使用其对应的API,这就大大的增加应用程序代码对于日志框架的耦合性. 为了解决这个问题,就是在日志框架和应用程序之间架设一个 ...
- Django - Jsonp、CORS
一.同源策略 https://www.cnblogs.com/yuanchenqi/articles/7638956.html 同源策略(Same origin policy)是一种约定,它是浏览器最 ...
- 邮件服务器Postfix的管理 重启php-fpm
Postfix邮件系统安装与配置:Postfix,Cyrus-IMAP,Cyrus-sasl,Dovecot和SPFhttp://www.freehao123.com/postfix-cyrus/Ce ...
- CSLA.Net学习(2)
采用CSLA.net 2.1.4.0版本的书写方式: using System; using System.ComponentModel; using Csla.Validation; using S ...
- mysqldump 导出统一限制每张数据表导出的记录数
mysqldump 导出统一限制每张数据表导出的记录数 在工作过程中,需要将生产的数据导出到本地开发环境,我希望可以导出部分数据.而服务器数据量比较大(上千万),如果选择直接从服务器导出数据, 正在运 ...
- POI - Excel API
一.概述 1. Apache POI是Apache软件基金会的开放源码函式库,POI提供API给java程式对Microsoft Office格式档案读和写的功能. 2. 结构 ...
- Docker学习笔记(一):在本地安装和配置Docker
由于公司里测试服务器时常会有变动,每次变动之后都需要在新的服务器上配置一遍环境,实在是麻烦.后来我突然想到了在网上看到的资料中说Docker能快速部署可移植的容器,所以我就试着用Docker搭建了 ...
- python selenium 安装与 chromedriver安装
安装 pip install selenium 安装完成之后运行脚本,如果没报错那ok.但是很不幸运,我报错啦.(本人使用ubuntu16.04,python2,or python3) 贴出我的报错: ...
- js文件被浏览器缓存
如果修改了js文件中的js代码,发布代码到线上后.用户的浏览器使用的还是原来js缓存.所以并不会马上生效. 如何才能让浏览器使用最新的js文件呢? 我去看了一下淘宝,发现也是这样一种方式额,不知道对不 ...
- ACM ICPC, Damascus University Collegiate Programming Contest(2018) Solution
A:Martadella Stikes Again 水. #include <bits/stdc++.h> using namespace std; #define ll long lon ...