Submission #987187

#TimeUsernameProblemLanguageResultExecution timeMemory
987187AdamGS장난감 기차 (IOI17_train)C++17
100 / 100
1065 ms1880 KiB
#include "train.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=5e3+7; vector<int>V[LIM], S[LIM]; int deg[LIM]; vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) { int n=a.size(), m=u.size(); vector<int>ans(n); rep(i, m) { V[u[i]].pb(v[i]); S[v[i]].pb(u[i]); } rep(i, n) { rep(j, n) { ans[j]=0; if(r[j]) deg[j]=0; else if(!a[j]) deg[j]=V[j].size(); else deg[j]=1; } queue<int>q; rep(j, n) if(deg[j]==0) q.push(j); while(!q.empty()) { int p=q.front(); q.pop(); ans[p]=1; for(auto j : S[p]) { --deg[j]; if(deg[j]==0) q.push(j); } } rep(j, n) if(r[j]) { int sum=0; for(auto l : V[j]) sum+=ans[l]; if(a[j] && sum==0 || !a[j] && sum<V[j].size()) r[j]=0; } } return ans; }

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:40:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |       if(a[j] && sum==0 || !a[j] && sum<V[j].size()) r[j]=0;
      |                                     ~~~^~~~~~~~~~~~
train.cpp:40:15: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   40 |       if(a[j] && sum==0 || !a[j] && sum<V[j].size()) r[j]=0;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...