Submission #1196805


Source Code Expand

Copy
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#define max 2005
int color[max+1];
int distance[max+1][max+1];
int edge[max+1][max+1];
void bfs(int k,int n){
    int sumi[max];
    int i;
    for(i=1;i<=n;i++)sumi[i]=0;
    std::queue<int>q;
    q.push(k);
    sumi[k]=1;
    distance[k][k]=0;
    while(!q.empty()){
        int point=q.front();q.pop();
        for(i=1;i<=n;i++){
            if(sumi[i]==0){
                if(edge[point][i]==1){
                distance[k][i]=distance[k][point]+1;
                sumi[i]=1;
                q.push(i);
                }
            }
        }
    }
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    int i,j;
    for(i=1;i<=m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        edge[a][b]=1;
        edge[b][a]=1;
    }
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)distance[i][j]=max+3;
    for(i=1;i<=n;i++){
        bfs(i,n);
    }
    int q;
    scanf("%d",&q);
    for(i=1;i<=q;i++){
        int v,d,c;
        scanf("%d %d %d",&v,&d,&c);
        for(j=1;j<=n;j++){
            if(distance[v][j]<=d){
                color[j]=c;
            }
        }
    }
    for(i=1;i<=n;i++){
        printf("%d\n",color[i]);
    }
    
    return 0;
}

Submission Info

Submission Time
Task B - Splatter Painting
User sugarrr
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1368 Byte
Status

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:36:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
                         ^
./Main.cpp:40:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&a,&b);
                             ^
./Main.cpp:49:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&q);
                   ^
./Main.cpp:52:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d",&v,&d,&c);
                                   ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 00_example_01.txt, 00_example_02.txt
Subtask1 0 / 200 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 0 / 500 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 1 ms 2304 KB
00_example_02.txt 1 ms 2304 KB
10_01.txt 6 ms 4864 KB
10_02.txt 2 ms 4480 KB
10_03.txt 2 ms 2304 KB
10_04.txt 2 ms 4352 KB
10_05.txt 6 ms 4864 KB
10_06.txt 1 ms 2304 KB
10_07.txt 16 ms 28928 KB
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 286 ms 11520 KB
20_06.txt
20_07.txt 153 ms 13440 KB
20_08.txt 296 ms 9984 KB
20_09.txt 79 ms 17408 KB
20_10.txt 122 ms 7296 KB
20_11.txt 936 ms 14208 KB
20_12.txt
20_13.txt
20_14.txt
20_15.txt
20_16.txt