Submission #55701032
Source Code Expand
#include <bits/stdc++.h>
//#include <bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
#define FOR_(i,s,e,d) for(int i = s; i < e; i+=d)
#define rep(i,s,e) FOR_(i,s,e,1)
#define rep2(i,s,e) for(int i = s; i >= e; i--)
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cout << vars << " = ";
string delim = "";
(..., (cout << delim << values, delim = ", "));
}
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
using vi = vector<int>;
using vii = vector<vector<int>>;
using pii = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
// using ost = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
std::istream& operator>>(std::istream& in, vector<T>& arr) {
for (T& t: arr) cin >> t;
return in;
}
void fast_io() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
}
int V, E, Q;
vector<pair<int,int>> colors;
vector<int> deg;
vector<vector<int>> g;
int main() {
fast_io(); cin >> V >> E;
deg.assign(V,0); colors.assign(V, {0,1}); g.assign(V, {});
for (int i = 0, u, v; i < E; i++) {
cin >> u >> v; u--; v--;
g[u].push_back(v);
g[v].push_back(u);
deg[u]++; deg[v]++;
}
const int SQRT_E = sqrt(E);
for (int cur = 0; cur < V; cur++) sort(g[cur].begin(), g[cur].end(), [&](const int u, const int v) { return deg[u] > deg[v]; });
cin >> Q;
const auto node_is_heavy = [&](int node) { return deg[node] >= SQRT_E;};
for (int q = 1, x , col; q <= Q; q++) {
cin >> x >> col; x--;
// get last color
pair<int,int> cur_color = colors[x];
for (int child: g[x]) {
if (!node_is_heavy(child)) break;
if (colors[child].first > abs(cur_color.first)) cur_color = colors[child];
}
cout << cur_color.second << '\n';
colors[x] = {q, col};
if (node_is_heavy(x)) continue;
for (int child: g[x]) colors[child] = {-q,col};
}
}
Submission Info
| Submission Time |
|
| Task |
083 - Colorful Graph(★6) |
| User |
JellyBoi1234 |
| Language |
C++ 20 (gcc 12.2) |
| Score |
0 |
| Code Size |
2573 Byte |
| Status |
WA |
| Exec Time |
168 ms |
| Memory |
17300 KiB |
Judge Result
| Set Name |
Sample |
Subtask1 |
Subtask2 |
| Score / Max Score |
0 / 0 |
0 / 2 |
0 / 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 |
1 ms |
3440 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3460 KiB |
| 10_random_small_00.txt |
AC |
1 ms |
3600 KiB |
| 10_random_small_01.txt |
WA |
1 ms |
3592 KiB |
| 10_random_small_02.txt |
AC |
1 ms |
3536 KiB |
| 11_random_large_00.txt |
AC |
2 ms |
3616 KiB |
| 11_random_large_01.txt |
AC |
13 ms |
4680 KiB |
| 11_random_large_02.txt |
AC |
17 ms |
5024 KiB |
| 11_subtask_00.txt |
WA |
33 ms |
5848 KiB |
| 11_subtask_01.txt |
WA |
13 ms |
4584 KiB |
| 11_subtask_02.txt |
WA |
15 ms |
4628 KiB |
| 11_subtask_03.txt |
AC |
4 ms |
3888 KiB |
| 11_subtask_04.txt |
AC |
8 ms |
4192 KiB |
| 11_subtask_05.txt |
WA |
24 ms |
5164 KiB |
| 11_subtask_06.txt |
AC |
15 ms |
4632 KiB |
| 11_subtask_07.txt |
AC |
17 ms |
4740 KiB |
| 11_subtask_08.txt |
AC |
11 ms |
4372 KiB |
| 11_subtask_09.txt |
WA |
25 ms |
5156 KiB |
| 20_random_max_00.txt |
AC |
102 ms |
16404 KiB |
| 20_random_max_01.txt |
AC |
98 ms |
16404 KiB |
| 60_random_challenge_00.txt |
AC |
54 ms |
4708 KiB |
| 60_random_challenge_01.txt |
AC |
47 ms |
4384 KiB |
| 60_random_challenge_02.txt |
AC |
36 ms |
3852 KiB |
| 70_random_clique_00.txt |
WA |
168 ms |
10784 KiB |
| 70_random_clique_01.txt |
WA |
168 ms |
10696 KiB |
| 80_random_tree_00.txt |
AC |
34 ms |
3900 KiB |
| 90_random_uni_00.txt |
WA |
69 ms |
17300 KiB |
| 90_random_uni_01.txt |
WA |
69 ms |
17268 KiB |
| 90_random_uni_02.txt |
WA |
70 ms |
17268 KiB |
| 99_random_kill_00.txt |
WA |
74 ms |
10584 KiB |
| 99_random_kill_01.txt |
WA |
75 ms |
10596 KiB |
| 99_random_kill_02.txt |
WA |
76 ms |
10524 KiB |