kakaの博客

你所热爱的,就是你的生活

0%

比赛链接:https://codeforces.com/contest/937

A. Olympiad

找有多少个不同的数,0不算

1
2
3
4
5
6
7
8
9
10
11
12
13
int a[N];
void solve() {
int n; cin >> n;
int f = 0;
set<int> st;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] == 0) f = 1;
st.insert(a[i]);
}
if (f) cout << st.size() - 1 << endl;
else cout << st.size() << endl;
}

B. Vile Grasshoppers

阅读全文 »

写在前面

关于我大学两年打了7场正式赛其中6场是线上的事

-2 Week

10月份最早得知ccpc桂林要办线下,估摸着就剩桂林可能是线下了,就算顶着一众强队报名也冲了,不去博弈什么了。

10月22日晚在我们死缠烂打下学校同意坐飞机去桂林(好耶),当晚直接订机票,真的兴奋了好久(小丑竟是我自己 )。离比赛还有2周左右的时间,虽然各地疫情开始爆发,广州也转线上了,但桂林还开始订酒店了?心想应该稳了吧。

阅读全文 »

比赛链接:https://codeforces.com/contest/1607

A. Linear Keyboard

暴力模拟题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void solve() {
int T; cin >> T; while (T--) {
string t; cin >> t;
string s; cin >> s;
vector<int> pos(100);
for (int i = 0; i < t.size(); i++) {
pos[t[i]-'a'] = i;
}
int ans = 0, now = pos[s[0]-'a'];
for (int i = 1; i < s.size(); i++) {
ans += abs(pos[s[i]-'a'] - now);
now = pos[s[i]-'a'];
}
cout << ans << endl;
}
}

B. Odd Grasshopper

阅读全文 »

比赛链接:https://codeforces.com/contest/1294

A. Collecting Coins

先将所有数补成相等,然后看剩下的是否是3的倍数即可

1
2
3
4
5
6
7
8
9
void solve() {
int a, b, c, n; cin >> a >> b >> c >> n;
if (a < b) swap(a, b);
if (a < c) swap(a, c);
int ans = a - b + a - c;
if (ans > n) cout << "NO" << endl;
else if ((ans-n)%3==0) cout << "YES" << endl;
else cout << "NO" << endl;
}

B. Collecting Packages

阅读全文 »

比赛链接:https://codeforces.com/contest/1107

A. Digits Sequence Dividing

考虑拆分成两个数,第一个数取一位,后面全部取为第二个数保证最优,当只有两个数且第一个小于等于第二个时输出NO

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void solve() {
int T; cin >> T; while (T--) {
int n; cin >> n;
string s; cin >> s;
if (n == 2) {
if (s[0] >= s[1]) cout << "NO" << endl;
else {
cout << "YES" << endl;
cout << 2 << endl;
cout << s[0] << ' ' << s[1] << endl;
}
} else {
cout << "YES" << endl;
cout << 2 << endl;
cout << s[0] << ' ';
for (int i = 1; i < s.size(); i++) cout << s[i];
cout << endl;
}
}
}

B - Digital root

阅读全文 »