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, ...
随机推荐
- Python开发【模块】:torndb
Torndb模块 概要:torndb是一个轻量级的基于MySQLdb封装的一个模块,其是tornado框架的一部分.其项目主页为:https://github.com/bdarnell/torndb ...
- Python开发【Django】:基础
Django基本配置 Python的WEB框架有Django.Tornado.Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM.模型绑定.模板引擎.缓存.Se ...
- 【Linux】通过top语句可以查看压力测试的实时服务器状态。(可以通过百度Linux top查看相关内容)
Linux实时查看服务器状态的两个语句 1.显示基本服务器监控状态语句如下:linux top 在这里输入 主要先看服务器负载高不高,高了后能否降下来,再看网络,io,数据库状态. 是有一个工具可以监 ...
- 002-spring cache 基于声明式注解的缓存-01-Cacheable annotation
一.简述 对于缓存声明,抽象提供了一组Java注解: @Cacheable触发缓存填充(这里一般放在创建和获取的方法上) @CacheEvict触发缓存驱逐(用于删除的方法上) @CachePut更新 ...
- [Axiom3D]第一个Axiom3D程序
Axiom3D程序的基本渲染流程 #region Namespace Declarations using System; using System.Linq; using Axiom.Core; u ...
- python 的 import 使用规则
对于含有 __init__.py 的目录(如adir),其实它就是一个package,它的子目录如果也包含 __init__.py,则只要将 adir 加入 sys.path,则它的字目录就不用加了, ...
- hbase Java API 介绍及使用示例
几个相关类与HBase数据模型之间的对应关系 java类 HBase数据模型 HBaseAdmin 数据库(DataBase) HBaseConfiguration HTable 表(Table) ...
- Ubuntu下virtualenv 的安装及使用
按照这个命令做下来基本是ok的. https://blog.csdn.net/qq_33371343/article/details/78047853
- C++类型前置声明
前言 本文总结了c++中前置声明的写法及注意事项,列举了哪些情况可以用前置声明来降低编译依赖. 前置声明的概念 前置声明:(forward declaration), 跟普通的声明一样,就是个声明, ...
- placement new--《C++必知必会》 条款35
placement new是重载operator new的一个标准.全局的版本,它不能被自定义的版本代替(不像普通的operator new和operator delete能够被替换成用户自定义的版本 ...