提出 #33272979
ソースコード 拡げる
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;
int main()
{
int n, m;
cin >> n >> m;
vector<int> a(m);
vector<int> b(m);
for (int i = 0; i < m; i++){
cin >> a[i] >> b[i];
a[i]--;
b[i]--;
}
vector<pair<int, int>> v(n, make_pair(-1, 1));
int q;
cin >> q;
vector<int> x(q);
vector<int> y(q);
vector<bool> used(n, false);
for (int i = 0; i < q; i++){
cin >> x[i] >> y[i];
x[i]--;
used[x[i]] = true;
}
vector<vector<int>> edges(n);
for (int i = 0; i < m; i++){
if (used[a[i]] && used[b[i]]){
edges[a[i]].push_back(b[i]);
edges[b[i]].push_back(a[i]);
}
}
// 次数が最大のノードだけ特別扱いする。
int maxsiz = 0;
int maxi = -1;
for (int i = 0; i < n; i++){
if (maxsiz <= edges[i].size()){
maxsiz = edges[i].size();
maxi = i;
}
}
if (maxi < 0){
cout << -1 << endl;
return 0;
}
vector<bool> edges_i(n, false);
for (int j : edges[maxi]){
edges_i[j] = true;
}
int coli = 1;
for (int i = 0; i < q; i++){
if (x[i] == maxi){
cout << coli << endl;
v[x[i]] = make_pair(i, y[i]);
coli = y[i];
} else {
auto [j, c] = v[x[i]];
for (int e : edges[x[i]]){
auto [j2, c2] = v[e];
if (j2 > j){
j = j2;
c = c2;
}
}
cout << c << endl;
v[x[i]] = make_pair(i, y[i]);
if (edges_i[x[i]]){
coli = y[i];
}
}
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | 083 - Colorful Graph(★6) |
| ユーザ | unnohideyuki |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 6 |
| コード長 | 1672 Byte |
| 結果 | AC |
| 実行時間 | 1727 ms |
| メモリ | 15764 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:52:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
52 | if (maxsiz <= edges[i].size()){
| ~~~~~~~^~~~~~~~~~~~~~~~~~
ジャッジ結果
| セット名 | Sample | Subtask1 | Subtask2 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 2 / 2 | 4 / 4 | ||||||
| 結果 |
|
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| Subtask1 | 11_subtask_00.txt, 11_subtask_01.txt, 11_subtask_02.txt, 11_subtask_03.txt, 11_subtask_04.txt, 11_subtask_05.txt, 11_subtask_06.txt, 11_subtask_07.txt, 11_subtask_08.txt, 11_subtask_09.txt |
| Subtask2 | 00_sample_00.txt, 00_sample_01.txt, 10_random_small_00.txt, 10_random_small_01.txt, 10_random_small_02.txt, 11_random_large_00.txt, 11_random_large_01.txt, 11_random_large_02.txt, 11_subtask_00.txt, 11_subtask_01.txt, 11_subtask_02.txt, 11_subtask_03.txt, 11_subtask_04.txt, 11_subtask_05.txt, 11_subtask_06.txt, 11_subtask_07.txt, 11_subtask_08.txt, 11_subtask_09.txt, 20_random_max_00.txt, 20_random_max_01.txt, 60_random_challenge_00.txt, 60_random_challenge_01.txt, 60_random_challenge_02.txt, 70_random_clique_00.txt, 70_random_clique_01.txt, 80_random_tree_00.txt, 90_random_uni_00.txt, 90_random_uni_01.txt, 90_random_uni_02.txt, 99_random_kill_00.txt, 99_random_kill_01.txt, 99_random_kill_02.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 18 ms | 3564 KiB |
| 00_sample_01.txt | AC | 2 ms | 3488 KiB |
| 10_random_small_00.txt | AC | 5 ms | 3640 KiB |
| 10_random_small_01.txt | AC | 2 ms | 3604 KiB |
| 10_random_small_02.txt | AC | 2 ms | 3620 KiB |
| 11_random_large_00.txt | AC | 18 ms | 3744 KiB |
| 11_random_large_01.txt | AC | 43 ms | 4148 KiB |
| 11_random_large_02.txt | AC | 61 ms | 4796 KiB |
| 11_subtask_00.txt | AC | 75 ms | 5472 KiB |
| 11_subtask_01.txt | AC | 39 ms | 4564 KiB |
| 11_subtask_02.txt | AC | 45 ms | 4744 KiB |
| 11_subtask_03.txt | AC | 17 ms | 3864 KiB |
| 11_subtask_04.txt | AC | 28 ms | 3660 KiB |
| 11_subtask_05.txt | AC | 62 ms | 5672 KiB |
| 11_subtask_06.txt | AC | 42 ms | 4508 KiB |
| 11_subtask_07.txt | AC | 47 ms | 4480 KiB |
| 11_subtask_08.txt | AC | 32 ms | 3976 KiB |
| 11_subtask_09.txt | AC | 63 ms | 5668 KiB |
| 20_random_max_00.txt | AC | 498 ms | 15608 KiB |
| 20_random_max_01.txt | AC | 500 ms | 15764 KiB |
| 60_random_challenge_00.txt | AC | 428 ms | 6532 KiB |
| 60_random_challenge_01.txt | AC | 412 ms | 6092 KiB |
| 60_random_challenge_02.txt | AC | 387 ms | 5144 KiB |
| 70_random_clique_00.txt | AC | 594 ms | 10428 KiB |
| 70_random_clique_01.txt | AC | 590 ms | 10428 KiB |
| 80_random_tree_00.txt | AC | 375 ms | 5408 KiB |
| 90_random_uni_00.txt | AC | 458 ms | 13720 KiB |
| 90_random_uni_01.txt | AC | 458 ms | 13760 KiB |
| 90_random_uni_02.txt | AC | 465 ms | 13808 KiB |
| 99_random_kill_00.txt | AC | 1727 ms | 10324 KiB |
| 99_random_kill_01.txt | AC | 1639 ms | 10376 KiB |
| 99_random_kill_02.txt | AC | 1692 ms | 10224 KiB |