Submission #19182561
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define x first
#define y second
#define bg begin()
#define ed end()
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define R(i,n) for(int i(0);i<(n);++i)
#define L(i,n) for(int i((n)-1);i>=0;--i)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;
//Data
const int N=1e5;
int n,m,ask_n,col[N],f[N],ask[N][3];
//Graph
vector<int> adj[N];
void adde(int u,int v)
{adj[u].pb(v),adj[v].pb(u);}
//Main
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>m;
R(i,m){
int u,v;
cin>>u>>v,--u,--v;
adde(u,v);
}
R(u,n) col[u]=f[u]=-1;
cin>>ask_n;
R(i,ask_n){
R(t,3) cin>>ask[i][t];
--ask[i][0],--ask[i][2];
}
L(i,ask_n){
queue<int> q;
int s=ask[i][0],d=ask[i][1],c=ask[i][2];
if(f[s]>=d) continue;
q.push(s),f[s]=ask[i][1];
if(!~col[s]) col[s]=c;
while(sz(q)){
int u=q.front();
q.pop();
for(int v:adj[u])if(f[v]<f[u]-1){
f[v]=f[u]-1,q.push(v);
if(!~col[v]) col[v]=c;
}
}
}
R(u,n) cout<<col[u]+1<<'\n';
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Splatter Painting |
| User | George1123 |
| Language | C++ (GCC 9.2.1) |
| Score | 700 |
| Code Size | 1339 Byte |
| Status | AC |
| Exec Time | 92 ms |
| Memory | 11452 KiB |
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 | 11 ms | 5888 KiB |
| 00_example_02.txt | AC | 5 ms | 5892 KiB |
| 10_01.txt | AC | 6 ms | 5848 KiB |
| 10_02.txt | AC | 4 ms | 5964 KiB |
| 10_03.txt | AC | 8 ms | 5888 KiB |
| 10_04.txt | AC | 5 ms | 5824 KiB |
| 10_05.txt | AC | 8 ms | 5872 KiB |
| 10_06.txt | AC | 6 ms | 5912 KiB |
| 10_07.txt | AC | 4 ms | 5980 KiB |
| 10_08.txt | AC | 10 ms | 5992 KiB |
| 10_09.txt | AC | 8 ms | 5948 KiB |
| 10_10.txt | AC | 6 ms | 5940 KiB |
| 10_11.txt | AC | 8 ms | 6008 KiB |
| 10_12.txt | AC | 10 ms | 6040 KiB |
| 10_13.txt | AC | 6 ms | 6020 KiB |
| 10_14.txt | AC | 6 ms | 5920 KiB |
| 10_15.txt | AC | 8 ms | 5984 KiB |
| 10_16.txt | AC | 10 ms | 6060 KiB |
| 10_17.txt | AC | 8 ms | 6016 KiB |
| 20_01.txt | AC | 92 ms | 10560 KiB |
| 20_02.txt | AC | 85 ms | 10628 KiB |
| 20_03.txt | AC | 88 ms | 10632 KiB |
| 20_04.txt | AC | 17 ms | 6684 KiB |
| 20_05.txt | AC | 7 ms | 5980 KiB |
| 20_06.txt | AC | 22 ms | 6728 KiB |
| 20_07.txt | AC | 13 ms | 6052 KiB |
| 20_08.txt | AC | 32 ms | 6884 KiB |
| 20_09.txt | AC | 7 ms | 5916 KiB |
| 20_10.txt | AC | 30 ms | 6796 KiB |
| 20_11.txt | AC | 36 ms | 7164 KiB |
| 20_12.txt | AC | 47 ms | 9540 KiB |
| 20_13.txt | AC | 73 ms | 10540 KiB |
| 20_14.txt | AC | 71 ms | 10552 KiB |
| 20_15.txt | AC | 67 ms | 11452 KiB |
| 20_16.txt | AC | 71 ms | 11440 KiB |