제출 #238074

#제출 시각아이디문제언어결과실행 시간메모리
238074Haunted_CppMatching (COCI20_matching)C++17
5 / 110
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; int main () { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; map<int, vector<int> > x, y; for (int i = 0; i < n; i++) { int foo, bar; cin >> foo >> bar; x[bar].emplace_back(i + 1); y[foo].emplace_back(i + 1); assert( (int) x[bar].size() <= 2); assert( (int) y[foo].size() <= 2); } auto solve = [&] (const map<int, vector<int>> &where) { int valid = 0; for (auto to : where) valid += ((int)to.second.size() == 2); if (valid == n / 2) { cout << "DA\n"; for (auto to : where) { cout << to.second[0] << ' ' << to.second[1] << '\n'; } return true; } return false; }; if (!solve(x) && !solve(y)) cout << "NE" << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...