제출 #1152664

#제출 시각아이디문제언어결과실행 시간메모리
1152664gelastropodTrobojnica (COCI19_trobojnica)C++20
0 / 110
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define int long long pair<bool, vector<pair<int, pair<int, int>>>> e(vector<pair<int, pair<int, int>>> A, int n) { for (int i = 0; i < n; i++) { if (A[i].first != A[(i + 1) % n].first) { A[i].first = 3 - (A[i].first + A[i + 1].first); A[i].second = { A[i].second.first, A[(i + 1) % n].second.second }; A.erase(A.begin() + (i + 1) % n); auto j = e(A, n - 1); if (j.first) { j.second.push_back(A[i]); return j; } } } return { false, {} }; } signed main() { int N; string s; cin >> N; cin >> s; vector<pair<int, pair<int, int>>> colours; for (int i = 0; i <= N; i++) colours.push_back({ s[i] - '0', {i, (i + 1) % N}}); auto asdasd = e(colours, N + 1); if (asdasd.first) { cout << "DA\n"; for (auto i : asdasd.second) { cout << i.second.first + 1 << ' ' << i.second.second + 1 << ' ' << i.first << '\n'; } } else cout << "NE\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...