# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
442555 | jesus_coconut | Trobojnica (COCI19_trobojnica) | C++17 | 2 ms | 204 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define dbg(x) cerr << #x << " = " << x << '\n';
#define F first
#define S second
using namespace std;
using ll = long long;
void solve() {
int n;
cin >> n;
list<pair<int, int>> l;
for (int i = 0; i < n; ++i) {
char c;
cin >> c;
l.push_back({i + 1, c - '0'});
}
vector<array<int, 3>> ans;
int cnt = 0;
for (auto it = l.begin(); cnt < 500000; ++cnt) {
auto sit = l.begin();
if (next(it) != l.end()) {
sit = next(it);
}
if (it->second != sit->second) {
auto nit = next(sit);
if (nit == l.end()) nit = l.begin();
if (next(nit) == it || (next(nit) == l.end() && l.begin() == it)) {
if (it->S + sit->S + nit->S != 6) {
cout << "NE\n";
return;
} else {
break;
}
}
ans.push_back({it->F, nit->F, 6 - it->S - sit->S});
it->second = 6 - it->S - sit->S;
l.erase(sit);
if (it != l.begin()) {
it = prev(it);
} else {
it = prev(l.end());
}
} else {
if (next(it) != l.end()) {
it = next(it);
} else it = l.begin();
}
if (ans.size() > n - 3) {
cout << "NE\n";
return;
}
}
if (ans.size() != n - 3) {
cout << "NE\n";
return;
}
cout << "DA\n";
for (auto &arr : ans) {
for (auto a : arr) {
cout << a << ' ';
}
cout << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
컴파일 시 표준 에러 (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... |