#include <bits/stdc++.h>
using namespace std;
#define inf 0x3F3F3F3F3F3F3F3F
const int MXN = 20 + 5;
const int mod = 1e9 + 7;
const int LOG = 20;
int n;
vector<array<int, 3>> res;
int ok(vector<array<int, 3>> v)
{
if (v.size() == 3)
{
return v[0][0] != v[1][0] && v[0][0] != v[2][0] && v[1][0] != v[2][0];
}
if (v[0][0] != v[1][0])
{
int x = 6 - v[0][0] - v[1][0];
array<int, 3> A = v[0], B = v[1];
v.erase(v.begin());
v.erase(v.begin());
v.push_back({x, A[1], B[2]});
if (ok(v))
{
res.push_back({A[1], B[2], x});
return 1;
}
v.insert(v.begin(), B);
v.insert(v.begin(), A);
}
if (v[1][0] != v[2][0])
{
int x = 6 - v[1][0] - v[2][0];
array<int, 3> A = v[1], B = v[2];
v.erase(v.begin() + 1);
v.erase(v.begin() + 1);
v.push_back({x, A[1], B[2]});
if (ok(v))
{
res.push_back({A[1], B[2], x});
return 1;
}
v.insert(v.begin() + 1, B);
v.insert(v.begin() + 1, A);
}
return 0;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
vector<array<int, 3>> v;
for (int i = 0; i < n; i++)
{
char ch;
cin >> ch;
v.push_back({ch - '0', i + 1, (i + 1) % n + 1});
}
if (!ok(v)) cout << "NE\n";
else
{
cout << "DA\n";
for (array<int, 3> &x : res) cout << x[0] << ' ' << x[1] << ' ' << x[2] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |