# Who = Penalty * A B C D E F
479 arkethos 4 247  

+

00:08

+

00:19

+1

00:59

+2

01:41

   
479  ne-leonardinkret 4 247  

+

00:04

-1

+1

00:27

+2

01:47

+

00:49

 
481 MeePwn# 4 248  

+

00:14

+

00:21

+

00:54

+3

01:39

   
482  shreypandey 4 251  

+

00:06

+

00:10

+

00:17

 

+5

01:58

 
483 iskander232 4 252  

+1

00:06

+2

00:23

+

00:17

-3

+2

01:46

 

Chess For Three

默认第一场比赛由AB进行

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
using std::vector;
using std::queue;
using std::map;
using std::sort;
using std::string;
using std::lower_bound;
using std::upper_bound;
#define read(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define write(x) printf("%d ", x)
#define writes(x) printf("%s ", x)
#define writeln(x) printf("%d\n", x)
#define writesln(x) printf("%s\n", x)
#define fillchar(x, a) memset(x, a, sizeof(x))
typedef long long llint;
/*data structure*/ /*data structure*/
int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
}
/*global variable*/
int a[];
/*global variable*/
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int n;
read(n);
for (int i = ; i < n; i++) {
read(a[i]);
a[i]--;
}
int p1 = , p2 = , spec = ;
bool flag1 = true;
for (int i = ; i < n; i++) {
if (a[i] == spec) {
flag1 = false;
break;
}
if (p1 == a[i]) {
int t = p2;
p2 = spec;
spec = t;
} else {
int t = p1;
p1 = spec;
spec = t;
}
}
if (flag1) printf("YES\n");
else printf("NO\n");
return ;
}

Beautiful Divisors

直接把符合条件的数列出来找

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
using std::vector;
using std::queue;
using std::map;
using std::sort;
using std::string;
using std::lower_bound;
using std::upper_bound;
#define read(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define write(x) printf("%d ", x)
#define writes(x) printf("%s ", x)
#define writeln(x) printf("%d\n", x)
#define writesln(x) printf("%s\n", x)
#define fillchar(x, a) memset(x, a, sizeof(x))
typedef long long llint;
/*data structure*/ /*data structure*/
int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
}
/*global variable*/
int a[];
/*global variable*/
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int n;
for (int i = ;; i++) {
a[i] = (( << i) - ) * ( << (i - ));
if (a[i] > ) {
n = i;
break;
}
}
int x;
read(x);
for (int i = n; i >= ; i--) {
if (x % a[i] == ) {
writeln(a[i]);
break;
}
}
return ;
}

Rumor

贪心,每次贿赂还不知道的人里边底线最低的

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<functional>
using std::priority_queue;
using std::vector;
using std::queue;
using std::map;
using std::sort;
using std::string;
using std::lower_bound;
using std::upper_bound;
#define read(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define write(x) printf("%d ", x)
#define writes(x) printf("%s ", x)
#define writeln(x) printf("%d\n", x)
#define writesln(x) printf("%s\n", x)
#define fillchar(x, a) memset(x, a, sizeof(x))
typedef long long llint;
/*data structure*/
struct cha {
int id;
llint c;
friend bool operator< (cha n1, cha n2) {
return n1.c > n2.c;
}
};
/*data structure*/
int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
}
/*global variable*/
priority_queue<cha> q;
vector<int> G[];
bool v[];
/*global variable*/
void dfs(int x) {
for (int i = ; i < G[x].size(); i++) {
int u = G[x][i];
if (v[u]) continue;
v[u] = true;
dfs(u);
}
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int n, m;
read(n);
read(m);
while (!q.empty()) q.pop();
for (int i = ; i <= n; i++) {
cha ccc;
ccc.id = i;
scanf("%lld", &ccc.c);
q.push(ccc);
G[i].clear();
}
for (int i = ; i < m; i++) {
int x, y;
read(x);
read(y);
G[x].push_back(y);
G[y].push_back(x);
}
fillchar(v, false);
long long ans = ;
while (!q.empty()) {
cha x = q.top();
q.pop();
if (v[x.id]) continue;
ans += x.c;
v[x.id] = true;
dfs(x.id);
}
printf("%I64d\n", ans);
return ;
}

Credit Card

首先,早上不存钱,把所有操作模拟一遍,记录每天晚上结束时的钱数m,如果某一天超过d,输出-1。

因为钱不会凭空消失,所以在某一天存入钱后,当天及以后每天的m值增加相同大小。

为了尽量少去,显然只有当a为0的日子才去,存的钱应该在不会导致之后超出d的情况下尽量多,为d减去之后的m值中最大的,再减去之前已经存过的钱数。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<functional>
using std::priority_queue;
using std::vector;
using std::queue;
using std::map;
using std::sort;
using std::string;
using std::lower_bound;
using std::upper_bound;
#define read(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define write(x) printf("%d ", x)
#define writes(x) printf("%s ", x)
#define writeln(x) printf("%d\n", x)
#define writesln(x) printf("%s\n", x)
#define fillchar(x, a) memset(x, a, sizeof(x))
typedef long long llint;
/*data structure*/ /*data structure*/
int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
}
/*global variable*/
int a[];
llint m[], max[];
/*global variable*/
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
int n;
llint d;
scanf("%d%I64d", &n, &d);
for (int i = ; i < n; i++) read(a[i]);
m[] = a[];
for (int i = ; i < n; i++) {
m[i] = m[i - ] + a[i];
}
for (int i = ; i < n; i++) {
if (m[i] > d) {
printf("-1\n");
return ;
}
}
max[n - ] = m[n - ];
for (int i = n - ; i >= ; i--) {
if (m[i] > max[i + ]) max[i] = m[i];
else max[i] = max[i + ];
}
int ans = ;
llint add = , l, r;
bool flag = true;
for (int i = ; i < n; i++) {
if (a[i] != ) continue;
if (m[i] + add >= ) continue;
l = (llint) - * m[i] - add;
r = d - (max[i] + add);
if (l > r) {
flag = false;
break;
}
ans++;
add += r;
}
if (flag) printf("%d\n", ans);
else printf("-1\n");
return ;
}

Counting Arrays

把x分解质因数,对于有cnt个的质因子,答案乘以C(y+cnt-1,cnt),关于这类问题,有一张总结的图(懒得编辑了,治疗一下颈椎病吧):

这题被这个数据搞了一下:

1
524288 1000000

这个524288=1<<19,y是最大值1000000,加起来就是1000018,而我数组开的是1000005,于是就跪了。脸打的啪啪啪,牛批啊老哥。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<functional>
#include<iostream>
//#include<bits/stdc++.h>
using namespace std;
#define fillchar(x, a) memset(x, a, sizeof(x))
typedef long long lint;
/*data structure*/
template <int size> class NoCombination {
public:
lint fac[size], inv[size], f[size];
lint mod;
void init(lint m) {
mod = m;
fac[] = fac[] = inv[] = inv[] = f[] = f[] = ;
for (int i = ; i < size; i++) {
fac[i] = fac[i - ] * i % mod;
f[i] = (mod - mod / i) * f[mod % i] % mod;
inv[i] = inv[i - ] * f[i] % mod;
}
}
lint C(lint a, lint b) {
return fac[a] * inv[b] % mod * inv[a - b] % mod;
}
};
/*data structure*/
int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
}
/*global variable*/
NoCombination<> nc;
const lint mod = ;
bool f[];
int p[], m = ;
/*global variable*/
/*function*/
inline lint pow(lint a, lint b, lint p) {
lint rtn = ;
while (b) {
if (b & ) rtn = rtn * a % p;
a = a * a % p;
b >>= ;
}
return rtn;
}
/*function*/
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(), cin.tie();
nc.init(mod);
fillchar(f, true);
f[] = f[] = false;
for (int i = ; i < ; i++) {
if (f[i]) {
p[m++] = i;
for (int j = i + i; j < ; j+=i) f[j] = false;
}
}
int q, x, y;
lint ans;
cin >> q;
while (q--) {
cin >> x >> y;
ans = ;
int maxp = (int)sqrt(x);
for (int i = ; i < m; i++) {
if (x == || p[i] > maxp) break;
if (x % p[i] != ) continue;
int cnt = ;
while (x % p[i] == ) x /= p[i], cnt++;
ans = ans * nc.C(y + cnt - , cnt) % mod;
}
if (x > ) ans = ans * y % mod;
ans = ans * pow(, y - , mod) % mod;
cout << ans << endl;
}
return ;
}
//

Subtree Minimum Query

这道题跟以前做过的一道题解法差不多,记录从每个点往下走1步,2步,4步,8步......能得到的最小的a,然后对于查询的k步用二进制表示出来各个位一凑就行。比如走7步相当于从第0个点走到第4个点的最小值、从第4个点走到第6个点的最小值、第6个点走到第7个点的最小值这3个最小值中的最小值,这样复杂度就变成了对数级别的。有几个可能会出错的坑,卡了我很久才弄明白,整理成两组测试数据:

2 1

1 2

1 2

1

1 100

4 1

10000 10000 10000 1

1 2

2 3

1 4

1

1 2

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<string>
#include<functional>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint; vector<int> G[];
vector<int> P[][];
int Q[][];
int a[], fa[], dep[];
vector<int> vi[]; int cmp(const void * x, const void * y) {
#define datatype int
datatype dx = *((datatype *)(x)), dy = *((datatype *)(y));
//x < y
return dx > dy ? : -;
#undef datatype
} void dfs(int x) {
for(int i = ; i < G[x].size(); i++) {
int u = G[x][i]; if(u == fa[x]) continue; fa[u] = x;
dfs(u); if(dep[u] + > dep[x]) dep[x] = dep[u] + ;
}
} int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
std::ios::sync_with_stdio(), cin.tie();
int n, r, x, y;
cin >> n >> r; for(int i = ; i <= n; i++) cin >> a[i]; for(int i = ; i < n; i++) {
cin >> x >> y;
G[x].push_back(y);
G[y].push_back(x);
} memset(fa, , sizeof(fa));
memset(dep, , sizeof(dep));
fa[r] = -;
dfs(r); for(int i = ; i <= n; i++) {
Q[i][] = a[i]; for(int j = ; j < G[i].size(); j++) {
int u = G[i][j]; if(u == fa[i]) continue; P[i][].push_back(u);
Q[i][] = min(Q[i][], a[u]);
}
} for(int j = ; j < ; j++) {
for(int i = ; i <= n; i++) {
Q[i][j] = Q[i][j - ]; for(int k = ; k < P[i][j - ].size(); k++) {
int u = P[i][j - ][k];
Q[i][j] = min(Q[i][j], Q[u][j - ]); for(int p = ; p < P[u][j - ].size(); p++) {
int v = P[u][j - ][p];
P[i][j].push_back(v);
}
}
}
} int t, p, q, cur, step, ans, last = ;
cin >> t; while(t--) {
cin >> p >> q; //p = (p + last) % n + 1, q = (q + last) % n;
if(q > dep[p]) q = dep[p]; int pp = p, qq = q;
vi[].clear(), vi[].clear();
ans = a[p];
cur = ;
vi[cur].push_back(p);
step = ; while(q) {
vi[ - cur].clear(); if(q & ) {
for(int i = ; i < vi[cur].size(); i++) {
int u = vi[cur][i];
ans = min(ans, Q[u][step]); for(int j = ; j < P[u][step].size(); j++) {
vi[ - cur].push_back(P[u][step][j]);
}
} cur = - cur;
} step++;
q >>= ;
} cout << ans << endl;
last = ans;
} return ;
}

Educational Codeforces Round 33的更多相关文章

  1. Educational Codeforces Round 33 (Rated for Div. 2) E. Counting Arrays

    题目链接 题意:给你两个数x,yx,yx,y,让你构造一些长为yyy的数列,让这个数列的累乘为xxx,输出方案数. 思路:考虑对xxx进行质因数分解,设某个质因子PiP_iPi​的的幂为kkk,则这个 ...

  2. Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query(主席树合并)

    题意 给定一棵 \(n\) 个点的带点权树,以 \(1\) 为根, \(m\) 次询问,每次询问给出两个值 \(p, k\) ,求以下值: \(p\) 的子树中距离 \(p \le k\) 的所有点权 ...

  3. Educational Codeforces Round 33 (Rated for Div. 2) 题解

    A.每个状态只有一种后续转移,判断每次转移是否都合法即可. #include <iostream> #include <cstdio> using namespace std; ...

  4. Educational Codeforces Round 33 (Rated for Div. 2)A-F

    总的来说这套题还是很不错的,让我对主席树有了更深的了解 A:水题,模拟即可 #include<bits/stdc++.h> #define fi first #define se seco ...

  5. Educational Codeforces Round 33 (Rated for Div. 2) D. Credit Card

    D. Credit Card time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  6. Educational Codeforces Round 33 (Rated for Div. 2) C. Rumor【并查集+贪心/维护集合最小值】

    C. Rumor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  7. Educational Codeforces Round 33 (Rated for Div. 2) B. Beautiful Divisors【进制思维/打表】

    B. Beautiful Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  8. Educational Codeforces Round 33 (Rated for Div. 2) A. Chess For Three【模拟/逻辑推理】

    A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Educational Codeforces Round 33 (Rated for Div. 2)

    A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...

随机推荐

  1. 函数式编程-将Monad(单子)融入Swift

    前言 近期又开始折腾起Haskell,掉进这个深坑恐怕很难再爬上来了.在不断深入了解Haskell的各种概念以及使用它们去解决实际问题的时候,我会试想着将这些概念移植到Swift中.函数式编程范式的很 ...

  2. 阿里云直播鉴权java代码示例

    段时间公司需要做直播服务,所以就研究了一下阿里云的直播,在直播里面,最重要的就是url的鉴权操作(验证推流或者拉流的有效性),在网上找了很多代码,都没有发现java的demo,所以就写篇播客记录一下, ...

  3. 连接mysql时遇到的问题

    1.报错:The server time zone value '???ú±ê×??±??' is unrecognized or represents 解决方法:在jdbc连接的url后面加上ser ...

  4. Python基础学习(day1)

    一.Python几点使用规范: 1.关于引号的使用规范 (1)字符串中含有单引号,则使用双引号外扩 print("It's ok") (2)字符串中含有双引号,则使用单引号外扩 p ...

  5. Selenium3+python自动化 -JS处理滚动条

    selenium并不是万能的,有时候页面上操作无法实现的,这时候就需要借助JS来完成了. 常见场景: 当页面上的元素超过一屏后,想操作屏幕下方的元素,是不能直接定位到,会报元素不可见的. 这时候需要借 ...

  6. eas之视图冻结与解冻

    // 冻结视图 table.getViewManager().freeze(verticalIndex, horizonIndex); //冻结视图:该方法在table还没显示的时候使用,也就是该方法 ...

  7. Python中字符串操作函数string.split('str1')和string.join(ls)

    Python中的字符串操作函数split 和 join能够实现字符串和列表之间的简单转换, 使用 .split()可以将字符串中特定部分以多个字符的形式,存储成列表 def split(self, * ...

  8. bzoj 2654 && bzoj 3675 总结

    手动博客搬家: 本文发表于20180929 15:18:55, 原地址https://blog.csdn.net/suncongbo/article/details/82897992 最近做到了两道( ...

  9. delphi窗口的create和free,一个古老的话题

    窗体分为模式窗体和无模式窗体. 模式窗体在创建窗口创建和释放: begin if not Assigned(FB_Input_JianYanDan) then FB_Input_JianYanDan ...

  10. 例说linux内核与应用数据通信(三):读写内核设备驱动文件

    [版权声明:尊重原创,转载请保留出处:blog.csdn.net/shallnet.文章仅供学习交流.请勿用于商业用途]         读写设备文件也就是调用系统调用read()和write(),系 ...