AtCoder Grand Contest 012

Submission #1587963

Source codeソースコード

#include <iostream>
#include <bits/stdc++.h>

#define si(x) scanf("%d",&x)
using namespace std;

int main()
{
    int n,m,q,x,y;
    si(n);si(m);
    vector<pair<int,int> > color(n);
    vector<int> last(n,-1);
    vector<vector<int> > adj(n);
    for(int i=0;i<n;i++)color[i] = {0,-1};
    for(int i=0;i<m;i++){
        si(x);si(y);
        adj[x-1].push_back(y-1);
        adj[y-1].push_back(x-1);
    }
    si(q);
    vector<pair<pair<int,int> , int > > query;
    for(int i=0;i<q;i++){
        int v,d,c;
        si(v);si(d);si(c);
        v--;
        query.push_back({{v,d},c});
    }
    for(int i=query.size()-1;i>=0;i--){
        queue<pair<int,int> > q;
        q.push({query[i].first.first , 0});
        while(!q.empty()){
            pair<int,int> curr = q.front();q.pop();
            if(color[curr.first].second == i)continue;
            if(last[curr.first] >= query[i].first.second - curr.second)continue;
            last[curr.first] = query[i].first.second - curr.second;
            if(color[curr.first].first == 0)color[curr.first].first = query[i].second;
            color[curr.first].second = i;
            if(curr.second == query[i].first.second)continue;
            for(int j=0;j<adj[curr.first].size();j++){
                q.push({adj[curr.first][j] , curr.second + 1});
            }
        }
    }
    for(int i=0;i<n;i++)cout << color[i].first << "\n";
    return 0;
}

Submission

Task問題 B - Splatter Painting
User nameユーザ名 vjudge5
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 700
Source lengthソースコード長 1403 Byte
File nameファイル名
Exec time実行時間 126 ms
Memory usageメモリ使用量 9712 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
si(n);si(m);
^
./Main.cpp:10:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
si(n);si(m);
^
./Main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
si(x);si(y);
^
./Main.cpp:16:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
si(x);si(y);
^
./Main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
si(q);
^
./Main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared wi...

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt
Subtask1 200 / 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 500 / 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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 1 ms 256 KB
10_08.txt AC 3 ms 384 KB
10_09.txt AC 3 ms 384 KB
10_10.txt AC 3 ms 384 KB
10_11.txt AC 3 ms 384 KB
10_12.txt AC 3 ms 384 KB
10_13.txt AC 2 ms 384 KB
10_14.txt AC 2 ms 384 KB
10_15.txt AC 2 ms 384 KB
10_16.txt AC 3 ms 384 KB
10_17.txt AC 3 ms 384 KB
20_01.txt AC 126 ms 8308 KB
20_02.txt AC 126 ms 8184 KB
20_03.txt AC 126 ms 8184 KB
20_04.txt AC 17 ms 1588 KB
20_05.txt AC 4 ms 472 KB
20_06.txt AC 13 ms 3968 KB
20_07.txt AC 5 ms 512 KB
20_08.txt AC 42 ms 2040 KB
20_09.txt AC 4 ms 512 KB
20_10.txt AC 38 ms 1912 KB
20_11.txt AC 55 ms 2040 KB
20_12.txt AC 50 ms 6848 KB
20_13.txt AC 98 ms 8184 KB
20_14.txt AC 106 ms 8056 KB
20_15.txt AC 98 ms 9456 KB
20_16.txt AC 100 ms 9712 KB