| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 251634 | MrRobot_28 | Trobojnica (COCI19_trobojnica) | C++17 | 59 ms | 7936 KiB | 
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<bits/stdc++.h>
using namespace std;
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	string s;
	cin >> n >> s;
	vector <int> nxt(n), color(n);
	vector <int> cnt(3);
	for(int i = 0; i < n; i++)
	{
		nxt[i] = (i + 1) % n;
		color[i] = s[i] - '1';
		cnt[s[i] - '1']++;
	}
	vector <int> ans1(n), ans2(n), ans3(n);
	int x = 0;
	for(int i = 0; i < n - 3; i++)
	{
		if(max(cnt[0], max(cnt[1], cnt[2])) == n - i)
		{
			cout << "NE";
			return 0;
		}
		while(color[x] == color[nxt[x]] || cnt[color[x]] == 1 && cnt[color[nxt[x]]] == 1)
		{
			x = nxt[x];
		}
		int y = nxt[x];
		cnt[color[x]]--;
		cnt[color[y]]--;
		ans1[i] = x;
		ans2[i] = nxt[y];
		color[x] = 3 - color[x] - color[y];
		nxt[x] = nxt[y];
		ans3[i] = color[x];
		cnt[color[x]]++;
	}
	if(cnt[0] == 1 && cnt[1] == 1)
	{
		cout << "DA\n";
		for(int i = 0; i < n - 3; i++)
		{
			cout << ans1[i] + 1 << " " << ans2[i] + 1 << " " << ans3[i] + 1 << "\n";
		}
	}
	else
	{
		cout << "NE";
	}
  	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
