Submission #28599

# Submission time Handle Problem Language Result Execution time Memory
28599 2017-07-16T07:51:10 Z 맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자(#1216, skdudn321, choiking10) Alternative Mart (FXCUP2_mart) C++
Compilation error
0 ms 0 KB
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
std::vector<std::pair<int,int>> G[50010];
std::vector<std::pair<int,int>> CK[50010];
struct node{
    int v, id, from;
};
bool operator<(node n1, node n2){
    return std::make_pair(-n1.v,n1.from) < std::make_pair(-n2.v,n2.from);
}
int main(){
    int N,M,K,Q;
    scanf("%d%d%d%d",&N,&M,&K,&Q);
    std::priority_queue<node> q;
    for(int i =0 ; i< K;i++){
        int v;
        scanf("%d",&v);
        q.push({0,v,v});
    }
    for(int i = 0; i < M ; i++){
        int A,B,C;
        scanf("%d%d%d",&A,&B,&C);
        G[A].push_back({B,C});
        G[B].push_back({A,C});
    }
    while(q.size() != 0){
        auto t = q.top();
        q.pop();
        if(CK[t.id].size() > 25) continue;
        bool flag = false;
        for(auto i : CK[t.id]){
            if(i.second == t.from) {
                flag = true;
                break;
            }
        }
        if(flag) continue;
        CK[t.id].push_back({t.v,t.from});

        for(auto i : G[t.id]){
            q.push({t.v+i.second,i.first,t.from});
        }
    }
    for(int i =0 ; i < Q;i ++){
        int S, X;
        scanf("%d%d",&S,&X);
        std::set<int> PC;
        for(int j =0; j < X; j++){
            int v;
            scanf("%d",&v);
            PC.insert(v);
        }
        std::sort(CK[S].begin(),CK[S].end());
        for(auto j : CK[S]){
            if(!PC.count(j.second)){
                printf("%d %d\n",j.second,j.first);
                break;
            }
        }
    }
}

Compilation message

mart.cpp:6:30: error: '>>' should be '> >' within a nested template argument list
 std::vector<std::pair<int,int>> G[50010];
                              ^
mart.cpp:7:30: error: '>>' should be '> >' within a nested template argument list
 std::vector<std::pair<int,int>> CK[50010];
                              ^
mart.cpp: In function 'int main()':
mart.cpp:21:16: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         q.push({0,v,v});
                ^
mart.cpp:21:23: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         q.push({0,v,v});
                       ^
mart.cpp:26:24: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         G[A].push_back({B,C});
                        ^
mart.cpp:26:29: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         G[A].push_back({B,C});
                             ^
mart.cpp:27:24: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         G[B].push_back({A,C});
                        ^
mart.cpp:27:29: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         G[B].push_back({A,C});
                             ^
mart.cpp:30:9: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
         auto t = q.top();
         ^
mart.cpp:30:14: error: 't' does not name a type
         auto t = q.top();
              ^
mart.cpp:32:15: error: 't' was not declared in this scope
         if(CK[t.id].size() > 25) continue;
               ^
mart.cpp:34:13: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
         for(auto i : CK[t.id]){
             ^
mart.cpp:34:18: error: 'i' does not name a type
         for(auto i : CK[t.id]){
                  ^
mart.cpp:40:9: error: expected ';' before 'if'
         if(flag) continue;
         ^
mart.cpp:40:9: error: expected primary-expression before 'if'
mart.cpp:40:9: error: expected ';' before 'if'
mart.cpp:40:9: error: expected primary-expression before 'if'
mart.cpp:40:9: error: expected ')' before 'if'
mart.cpp:41:12: error: 't' was not declared in this scope
         CK[t.id].push_back({t.v,t.from});
            ^
mart.cpp:41:28: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
         CK[t.id].push_back({t.v,t.from});
                            ^
mart.cpp:43:13: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
         for(auto i : G[t.id]){
             ^
mart.cpp:43:18: error: 'i' does not name a type
         for(auto i : G[t.id]){
                  ^
mart.cpp:46:5: error: expected ';' before '}' token
     }
     ^
mart.cpp:46:5: error: expected primary-expression before '}' token
mart.cpp:46:5: error: expected ';' before '}' token
mart.cpp:46:5: error: expected primary-expression before '}' token
mart.cpp:46:5: error: expected ')' before '}' token
mart.cpp:46:5: error: expected primary-expression before '}' token
mart.cpp:57:13: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
         for(auto j : CK[S]){
             ^
mart.cpp:57:18: error: 'j' does not name a type
         for(auto j : CK[S]){
                  ^
mart.cpp:63:5: error: expected ';' before '}' token
     }
     ^
mart.cpp:63:5: error: expected primary-expression before '}' token
mart.cpp:63:5: error: expected ';' before '}' token
mart.cpp:63:5: error: expected primary-expression before '}' token
mart.cpp:63:5: error: expected ')' before '}' token
mart.cpp:63:5: error: expected primary-expression before '}' token
mart.cpp:16:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d",&N,&M,&K,&Q);
                                  ^
mart.cpp:20:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&v);
                       ^
mart.cpp:25:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&A,&B,&C);
                                 ^
mart.cpp:49:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&S,&X);
                            ^
mart.cpp:53:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&v);
                           ^