| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 331769 | thecodingwizard | Izlet (COI19_izlet) | C++11 | 591 ms | 53740 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define inf 1000000010
#define maxn 3000
int n;
int input[maxn][maxn];
vector<int> nodes; // stores nodes remaining after 1's are compressed
map<int, vector<int>> nodesInOneComponent;
void compressOnes() {
vector<bool> done(n, 0);
F0R(i, n) {
if (done[i]) continue;
nodes.pb(i);
done[i] = true;
F0R(j, n) {
if (input[i][j] == 1 && j != i) {
nodesInOneComponent[i].pb(j);
done[j] = true;
}
}
}
}
void findTwos() {
}
int assignedColor[maxn];
vector<ii> outputEdges;
void buildTree() {
assignedColor[nodes[0]] = 1;
FOR(i, 1, nodes.size()) {
outputEdges.emplace_back(nodes[0], nodes[i]);
assignedColor[nodes[i]] = 2;
}
}
void decompressOnes() {
for (int x : nodes) {
for (int y : nodesInOneComponent[x]) {
outputEdges.pb(mp(x, y));
assignedColor[y] = assignedColor[x];
}
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int subtask; cin >> subtask; assert(subtask == 1);
cin >> n;
F0R(i, n) {
F0R(j, n) {
cin >> input[i][j];
}
}
compressOnes();
findTwos();
buildTree();
decompressOnes();
F0R(i, n) cout << assignedColor[i] << " ";
cout << endl;
for (auto x : outputEdges) cout << x.f+1 << " " << x.s+1 << endl;
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... | ||||
