#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];
}
vector<array<int, 3>> org = v;
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.insert(v.begin(), {x, A[1], B[2]});
if (ok(v))
{
res.push_back({A[1], B[2], x});
return 1;
}
}
v = org;
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.insert(v.begin() + 1, {x, A[1], B[2]});
if (ok(v))
{
res.push_back({A[1], B[2], x});
return 1;
}
}
return 0;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << "DA\n1 3 3";
return 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';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |