目录
B - Who is missing? (atcoder.jp)
A - chukodai Editorial
A - chukodai (atcoder.jp)
题意:交换两个位置的字符串
完整代码:
#include <bits/stdc++.h>
#define int long long
#define PII std::pair<int,int>
const int N = 1e5 + 10;
int a[N];
signed main() {
std::string s;
std::cin >> s;
int n = s.length();
s = " " + s;
int x, y;
std::cin >> x >> y;
char s1 = s[x], s2 = s[y];
for (int i = 1; i <= n; i++) {
if (i == x) {
std::cout << s2;
continue;
}
if (i == y) {
std::cout << s1;
continue;
}
std::cout << s[i];
}
return 0;
}
B - Who is missing?
B - Who is missing? (atcoder.jp)
题意:找出 被拿走的那张牌
思路:异或运算
完整代码:
#include <bits/stdc++.h>
#define int long long
#define PII std::pair<int,int>
const int N = 1e5 + 10;
//int a[N];
signed main() {
int n;
std::cin >> n;
int m = 4 * n - 1;
int x=0;
for (int i = 1; i <= m; i++) {
int y;
std::cin >> y;
x^=y;
}
std::cout<<x;
return 0;
}