This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <array>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
struct node {
int color;
int lower;
node* prev;
node* next;
};
struct diag {
int a, b, color;
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
string s;
cin >> s;
vector<node> nodes(n);
vector<node*> next_different;
array<int, 3> cnts = { 0, 0, 0 };
for (int i = 0; i < n; i++) {
nodes[i].color = (s[i] - '0') % 3;
nodes[i].lower = i;
cnts[nodes[i].color]++;
nodes[i].prev = &nodes[i > 0 ? i - 1 : n - 1];
nodes[i].next = &nodes[i + 1 < n ? i + 1 : 0];
}
if (count(cnts.begin(), cnts.end(), n) || cnts[0] % 2 != n % 2 || cnts[1] % 2 != n % 2 || cnts[2] % 2 != n % 2) {
cout << "NE\n";
return 0;
}
int node_cnt = n;
vector<diag> diagonals(n - 3, { 1, 1, 1 });
while (node_cnt > 3) {
// TODO
node_cnt--;
}
cout << "DA\n";
for (auto const& [a, b, c] : diagonals) {
cout << a << " " << b << " " << c << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |