Codeforces Round 959 (Div. 1 + Div. 2) editorial

Revision en4, by zwezdinv, 2024-07-18 19:20:12

Thanks for participation!

1994A - Diverse Game

Editorial
Code

1994B - Fun Game

Editorial
Code

1994C - Hungry Games

Editorial
Code

1994D - Funny Game

Hint

Editorial

Tutorial is loading...

Code

include<bits/stdc++.h>

using namespace std;

int main() { int tests; cin >> tests; while (tests--) { int n; cin >> n; vector a(n); for (auto& i : a) cin >> i; vector pos(n); iota(pos.begin(), pos.end(), 0); vector<pair<int, int>> ans; for (int i = n — 1; i; --i) { vector occ(i, -1); for (auto j : pos) { if (occ[a[j] % i] != -1) { ans.emplace_back(j, occ[a[j] % i]); pos.erase(find(pos.begin(), pos.end(), j)); break; } occ[a[j] % i] = j; } } reverse(ans.begin(), ans.end()); cout << "YES\n"; for (auto [x, y] : ans) cout << x + 1 << ' ' << y + 1 << '\n'; } } ~~~~~

Tags editorial

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en13 English zwezdinv 2024-07-18 19:54:18 1 (published)
ru3 Russian zwezdinv 2024-07-18 19:50:24 1 (опубликовано)
ru2 Russian zwezdinv 2024-07-18 19:34:01 574 Первая редакция перевода на Русский
ru1 Russian zwezdinv 2024-07-18 19:31:03 9417 Первая редакция перевода на Русский (сохранено в черновиках)
en12 English zwezdinv 2024-07-18 19:27:01 1
en11 English zwezdinv 2024-07-18 19:26:18 72
en10 English zwezdinv 2024-07-18 19:25:38 1
en9 English zwezdinv 2024-07-18 19:25:03 188
en8 English zwezdinv 2024-07-18 19:23:51 6416
en7 English zwezdinv 2024-07-18 19:22:57 4 Tiny change: 'inciple\n<\spoiler>\n' -> 'inciple\n</spoiler>\n'
en6 English zwezdinv 2024-07-18 19:22:36 6417
en5 English zwezdinv 2024-07-18 19:22:17 6413
en4 English zwezdinv 2024-07-18 19:20:12 6221
en3 English zwezdinv 2024-07-18 19:17:18 807
en2 English zwezdinv 2024-07-18 19:12:32 5535
en1 English zwezdinv 2024-07-18 19:07:57 3137 Initial revision (saved to drafts)