Submission #24935840
Source Code Expand
#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = (1LL << 61); ll mod = 1000000007; int N, M; vector<int>G[200010], G2[200010]; int c[200010]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M; vector<int>A(M), B(M); for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); A[i] = a, B[i] = b; } int T = sqrt(2 * M * 100); vector<bool>is_big(N); for (int i = 0; i < N; i++) { if ((int)(G[i].size()) >= T) { is_big[i] = true; } } for (int i = 0; i < M; i++) { if (is_big[B[i]])G2[A[i]].push_back(B[i]); if (is_big[A[i]])G2[B[i]].push_back(A[i]); } for (int i = 0; i < N; i++)c[i] = 1; int Q; cin >> Q; vector<int>x(Q), y(Q); vector<int>wh(N, -1); for (int i = 0; i < Q; i++) { cin >> x[i] >> y[i]; x[i]--; if (is_big[x[i]]) { cout << c[x[i]] << endl; c[x[i]] = y[i]; for (auto nv : G2[x[i]]) { c[nv] = y[i]; } } else { int now = -1; now = max(now, wh[x[i]]); for (auto nv : G[x[i]]) { now = max(now, wh[nv]); } if (now == -1)cout << 1 << endl; else cout << y[now] << endl; c[x[i]] = y[i]; for (auto nv : G2[x[i]]) { c[nv] = y[i]; } } wh[x[i]] = i; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | 083 - Colorful Graph(★6) |
User | Example |
Language | C++ (GCC 9.2.1) |
Score | 6 |
Code Size | 1384 Byte |
Status | AC |
Exec Time | 486 ms |
Memory | 35932 KiB |
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 2 / 2 | 4 / 4 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 14 ms | 12984 KiB |
00_sample_01.txt | AC | 14 ms | 12896 KiB |
10_random_small_00.txt | AC | 14 ms | 13124 KiB |
10_random_small_01.txt | AC | 11 ms | 13024 KiB |
10_random_small_02.txt | AC | 13 ms | 12924 KiB |
11_random_large_00.txt | AC | 25 ms | 13184 KiB |
11_random_large_01.txt | AC | 37 ms | 15736 KiB |
11_random_large_02.txt | AC | 49 ms | 17076 KiB |
11_subtask_00.txt | AC | 50 ms | 20528 KiB |
11_subtask_01.txt | AC | 27 ms | 15768 KiB |
11_subtask_02.txt | AC | 36 ms | 16632 KiB |
11_subtask_03.txt | AC | 24 ms | 13472 KiB |
11_subtask_04.txt | AC | 27 ms | 14396 KiB |
11_subtask_05.txt | AC | 44 ms | 18624 KiB |
11_subtask_06.txt | AC | 35 ms | 16568 KiB |
11_subtask_07.txt | AC | 34 ms | 17052 KiB |
11_subtask_08.txt | AC | 25 ms | 15044 KiB |
11_subtask_09.txt | AC | 45 ms | 18680 KiB |
20_random_max_00.txt | AC | 470 ms | 29564 KiB |
20_random_max_01.txt | AC | 466 ms | 29520 KiB |
60_random_challenge_00.txt | AC | 368 ms | 19268 KiB |
60_random_challenge_01.txt | AC | 361 ms | 18228 KiB |
60_random_challenge_02.txt | AC | 348 ms | 16388 KiB |
70_random_clique_00.txt | AC | 484 ms | 25204 KiB |
70_random_clique_01.txt | AC | 486 ms | 25320 KiB |
80_random_tree_00.txt | AC | 352 ms | 16528 KiB |
90_random_uni_00.txt | AC | 438 ms | 35864 KiB |
90_random_uni_01.txt | AC | 432 ms | 35904 KiB |
90_random_uni_02.txt | AC | 435 ms | 35932 KiB |
99_random_kill_00.txt | AC | 415 ms | 27796 KiB |
99_random_kill_01.txt | AC | 416 ms | 27884 KiB |
99_random_kill_02.txt | AC | 410 ms | 27836 KiB |