Submission #1197589
Source Code Expand
#include<stdio.h>
#include<vector>
#include<queue>
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x) { int k, m = 0; *x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { *x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; *x = (*x) * 10 + k - '0'; }if (m)(*x) = -(*x); }
void reader(int *x, int *y) { reader(x); reader(y); }
void reader(int *x, int *y, int *z) { reader(x); reader(y); reader(z); }
void writer(int x, char c) { int i, sz = 0, m = 0; char buf[10]; if (x<0)m = 1, x = -x; while (x)buf[sz++] = x % 10, x /= 10; if (!sz)buf[sz++] = 0; if (m)mypc('-'); while (sz--)mypc(buf[sz] + '0'); mypc(c); }
vector<int>E[100000];
int d1[100000];
int c1[100000], c2[100000];
int que[100000];
int v[100000], d[100000], c[100000];
int mq[100000];
signed main() {
int n, m; reader(&n, &m);
rep(i, m) {
int a, b; reader(&a, &b); a--; b--;
E[a].push_back(b); E[b].push_back(a);
}
memset(c2, -1, sizeof(c2));
int q; reader(&q);
rep(i, q) {
reader(&v[i], &d[i], &c[i]); v[i]--;
}
memset(mq, -1, sizeof(mq));
for (int i = q - 1; i >= 0; i--) {
int s = 0, g = 0;
if (c2[v[i]] == -1) { c1[v[i]] = c[i]; mq[v[i]] = d[i]; c2[v[i]] = i; }
d1[v[i]] = 0;
if (d1[v[i]] < d[i])que[g++] = v[i];
while (s != g) {
int p = que[s++];
int siz = E[p].size();
rep(j, siz) {
int u = E[p][j];
if (mq[u] >= d[i] - d1[u])continue;
if (c2[u] == -1) {
c1[u] = c[i]; c2[u] = i; d1[u] = d1[p] + 1;
mq[u] = d[i] - d1[u];
}
if (d1[u] < d[i])que[g++] = u;
}
}
}
rep(i, n)writer(c1[i], '\n');
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
autumn_eel |
Language |
C++14 (Clang 3.8.0) |
Score |
0 |
Code Size |
1952 Byte |
Status |
RE |
Exec Time |
2104 ms |
Memory |
9208 KB |
Judge Result
Set Name |
Sample |
Subtask1 |
All |
Score / Max Score |
0 / 0 |
0 / 200 |
0 / 500 |
Status |
|
|
AC |
× 5 |
WA |
× 3 |
TLE |
× 2 |
RE |
× 25 |
|
Set Name |
Test Cases |
Sample |
00_example_01.txt, 00_example_02.txt |
Subtask1 |
00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt |
All |
00_example_01.txt, 00_example_02.txt, 10_01.txt, 10_02.txt, 10_03.txt, 10_04.txt, 10_05.txt, 10_06.txt, 10_07.txt, 10_08.txt, 10_09.txt, 10_10.txt, 10_11.txt, 10_12.txt, 10_13.txt, 10_14.txt, 10_15.txt, 10_16.txt, 10_17.txt, 20_01.txt, 20_02.txt, 20_03.txt, 20_04.txt, 20_05.txt, 20_06.txt, 20_07.txt, 20_08.txt, 20_09.txt, 20_10.txt, 20_11.txt, 20_12.txt, 20_13.txt, 20_14.txt, 20_15.txt, 20_16.txt |
Case Name |
Status |
Exec Time |
Memory |
00_example_01.txt |
AC |
3 ms |
4736 KB |
00_example_02.txt |
AC |
5 ms |
5760 KB |
10_01.txt |
RE |
118 ms |
5760 KB |
10_02.txt |
AC |
3 ms |
4736 KB |
10_03.txt |
WA |
5 ms |
5760 KB |
10_04.txt |
AC |
3 ms |
4736 KB |
10_05.txt |
RE |
105 ms |
5760 KB |
10_06.txt |
RE |
102 ms |
5760 KB |
10_07.txt |
AC |
3 ms |
4736 KB |
10_08.txt |
RE |
105 ms |
5760 KB |
10_09.txt |
RE |
105 ms |
5760 KB |
10_10.txt |
RE |
108 ms |
5760 KB |
10_11.txt |
WA |
6 ms |
5760 KB |
10_12.txt |
RE |
105 ms |
5760 KB |
10_13.txt |
RE |
105 ms |
5760 KB |
10_14.txt |
RE |
104 ms |
5760 KB |
10_15.txt |
RE |
105 ms |
5760 KB |
10_16.txt |
RE |
109 ms |
5760 KB |
10_17.txt |
RE |
112 ms |
5760 KB |
20_01.txt |
RE |
143 ms |
8448 KB |
20_02.txt |
RE |
138 ms |
8448 KB |
20_03.txt |
RE |
139 ms |
8448 KB |
20_04.txt |
RE |
130 ms |
6400 KB |
20_05.txt |
RE |
105 ms |
5760 KB |
20_06.txt |
WA |
8 ms |
5888 KB |
20_07.txt |
RE |
105 ms |
5760 KB |
20_08.txt |
RE |
131 ms |
5888 KB |
20_09.txt |
RE |
105 ms |
5760 KB |
20_10.txt |
RE |
113 ms |
5760 KB |
20_11.txt |
RE |
130 ms |
5888 KB |
20_12.txt |
RE |
123 ms |
8576 KB |
20_13.txt |
RE |
132 ms |
8704 KB |
20_14.txt |
RE |
132 ms |
8576 KB |
20_15.txt |
TLE |
2104 ms |
9208 KB |
20_16.txt |
TLE |
2104 ms |
9208 KB |