- 【CPR-1-Div.2】Code Paradise 第一场OI
【CPR-1-Div.2】Code Paradise 第一场OI 赛后答疑帖 & 赛后题解
- 2023-8-14 10:28:52 @
A 積雪深差:
# include <bits/stdc++.h>
using namespace std;
int main() {
long long a, b;
scanf("%lld%lld", &a, &b);
printf("%lld", a - b);
return 0;
}
B hacker:
# include <bits/stdc++.h>
using namespace std;
int T;
long long n, m;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%lld%lld", &n, &m);
if (n == m) {
printf("0\n");
continue;
}
if ((n | m) == n || (n | m) == m) {
printf("1\n");
} else {
printf("2\n");
}
}
return 0;
}
C 存在:
# include <bits/stdc++.h>
using namespace std;
int n, a = 2, b = 0;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
if (b == 0) {
cout << a << " ";
a++;
b = 2;
} else {
b--;
cout << 1 << " ";
}
}
return 0;
}
D queue:
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
struct node {
string s; int id;
bool operator < (const node &rhs) const {
return id < rhs.id;
}
}; set<node> q;
map<string, int> inq;
map<string, bool> ing;
inline bool try_insert(string s) {
if (inq[s] || ing[s]) {
return 0;
}
int x = q.empty() ? 0 : prev(q.end())->id;
return q.insert({ s, inq[s] = x + 1 }), 1;
}
inline bool try_erase(string s) {
if (!inq[s]) {
return 0;
}
return q.erase({ s, inq[s] }), inq[s] = 0, 1;
}
string t[2]; int num;
inline void try_start() {
for (int i = 0; i < num; i++) {
ing[t[i]] = 0, try_insert(t[i]);
}
num = min<int>(2, q.size());
if (!num) {
return puts("Error"), void();
}
for (int i = 0; i < num; i++) {
try_erase(t[i] = q.begin()->s), ing[t[i]] = 1;
cout << t[i] << " ";
}
puts("");
}
int n;
string opt, s;
int main() {
scanf("%d", &n);
while (n--) {
cin >> opt;
if (opt[0] == 'a') {
cin >> s;
puts(try_insert(s) ? "OK" : "Error");
}
if (opt[0] == 'l') {
cin >> s;
puts(try_erase(s) ? "OK" : "Error");
}
if (opt[0] == 's') {
try_start();
}
}
}
3 条评论
-
张瀚予 LV 5 @ 2023-8-27 13:16:23
帮忙讲一下
-
2023-8-27 13:13:33@
d题我还是不会
-
2023-8-16 9:05:29@
qp
- 1