1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ABC213

灰 灰 茶 茶 水 黃 ? 赤

A - Bitwise Exclusive Or

B xor Aを実装する
^を使えば良いので(B ^ A)とすれば良い
出力にそのままB ^ Aを入れると優先順位で負けるのでカッコを付ける

ABC213_A
int A, B; cin >> A >> B;
cout << (B ^ A) << endl;

B - Booby Prize

リストにpair方でスコアとナンバーを記録してソートをかけて(後ろから)2番めを出力

ABC213_B
int N; cin >> N;
vector<pair<int, int>> A(N);
for (int i = 0; i < N; i++) {
    int x ; cin >> x;
    A[i] = make_pair(x, i);
}
sort(all(A));
cout << A[N - 2].second + 1 << endl;

C - Reorder Cards

ザ座標圧縮

理解しきることはできなかったので自分なりにアレンジ
重複を削除したリストを作りソートをかける
小さい方から順に数字を割り当て、それをsetにいれる
setを経由することで番号を更新する

今回の問題はX軸Y軸があるが別々に独立で考えて良い

重複の処理に注意
eraseはソートをかけてから!(1敗

ABC213_C
int H, W, N; cin >> H >> W >> N;
vector<int> X(N), Y(N);
for (int i = 0; i < N; i++) cin >> X[i] >> Y[i];
vector<int> x = X, y = Y;
sort(all(x));
x.erase(unique(all(x)), x.end());
sort(all(y));
y.erase(unique(all(y)), y.end());
map<int, int> Mx, My;
for (int i = 0; i < x.size(); i++) {
    Mx[x[i]] = i;
}
for (int i = 0; i < y.size(); i++) {
    My[y[i]] = i;
}
for (int i = 0; i < N; i++) {
    cout << Mx.at(X[i]) + 1 << ' ' << My.at(Y[i]) + 1 << endl;;
}

まとめ

今日は3問だけ
4問目DFS中なんですけど関数でやるの苦手で避けてたら必須ぽかったのでやり直す事になってますー
時間ないので明日追記します
5月8日

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?