Submission #1195005
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }
int main() {
int N; int M;
while (~scanf("%d%d", &N, &M)) {
vector<vector<int> > g(N);
for (int i = 0; i < M; ++ i) {
int u, v;
scanf("%d%d", &u, &v), -- u, -- v;
g[u].push_back(v);
g[v].push_back(u);
}
int Q;
scanf("%d", &Q);
const int D = 10;
vector<vector<pair<int, int>>> paints(D + 1, vector<pii>(N, make_pair(0, 0)));
rep(i, Q) {
int u; int d; int c;
scanf("%d%d%d", &u, &d, &c), -- u;
amax(paints[d][u], make_pair(i + 1, c));
}
for (int d = D; d > 0; -- d) {
rep(i, N) {
auto p = paints[d][i];
if (p.first == 0) continue;
amax(paints[d - 1][i], p);
for (int j : g[i])
amax(paints[d - 1][j], p);
}
}
rep(i, N)
printf("%d\n", paints[0][i].second);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
B - Splatter Painting |
User |
anta |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1373 Byte |
Status |
AC |
Exec Time |
107 ms |
Memory |
15480 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:17:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &u, &v), -- u, -- v;
^
./Main.cpp:22:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &Q);
^
./Main.cpp:27:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &u, &d, &c), -- u;
^
Judge Result
Set Name |
Sample |
Subtask1 |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
500 / 500 |
Status |
|
|
|
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 |
1 ms |
256 KB |
00_example_02.txt |
AC |
1 ms |
256 KB |
10_01.txt |
AC |
2 ms |
256 KB |
10_02.txt |
AC |
1 ms |
256 KB |
10_03.txt |
AC |
1 ms |
256 KB |
10_04.txt |
AC |
1 ms |
256 KB |
10_05.txt |
AC |
2 ms |
256 KB |
10_06.txt |
AC |
1 ms |
256 KB |
10_07.txt |
AC |
2 ms |
476 KB |
10_08.txt |
AC |
3 ms |
512 KB |
10_09.txt |
AC |
3 ms |
512 KB |
10_10.txt |
AC |
3 ms |
512 KB |
10_11.txt |
AC |
3 ms |
512 KB |
10_12.txt |
AC |
3 ms |
512 KB |
10_13.txt |
AC |
2 ms |
512 KB |
10_14.txt |
AC |
2 ms |
512 KB |
10_15.txt |
AC |
2 ms |
512 KB |
10_16.txt |
AC |
3 ms |
512 KB |
10_17.txt |
AC |
3 ms |
512 KB |
20_01.txt |
AC |
103 ms |
14720 KB |
20_02.txt |
AC |
104 ms |
14720 KB |
20_03.txt |
AC |
107 ms |
14720 KB |
20_04.txt |
AC |
16 ms |
1792 KB |
20_05.txt |
AC |
3 ms |
384 KB |
20_06.txt |
AC |
16 ms |
11392 KB |
20_07.txt |
AC |
3 ms |
384 KB |
20_08.txt |
AC |
17 ms |
384 KB |
20_09.txt |
AC |
3 ms |
384 KB |
20_10.txt |
AC |
16 ms |
256 KB |
20_11.txt |
AC |
22 ms |
384 KB |
20_12.txt |
AC |
56 ms |
13696 KB |
20_13.txt |
AC |
83 ms |
14336 KB |
20_14.txt |
AC |
85 ms |
13824 KB |
20_15.txt |
AC |
73 ms |
15480 KB |
20_16.txt |
AC |
82 ms |
15480 KB |