Submission #128343

# Submission time Handle Problem Language Result Execution time Memory
128343 2019-07-10T18:49:49 Z Harry464 Wand (COCI19_wand) C++14
63 / 70
134 ms 5956 KB
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector <int> red;
  vector <vector <int> > adjl(n,red);
  for (int i = 0; i < m; i++){
    int u, v;
    cin >> v >> u;
    adjl[u-1].push_back(v-1);
  }
  queue <int> bfs;
  bfs.push(0);
  bool mog = false;
  vector <bool> vis(n);
  while (!bfs.empty()){
   int s = bfs.front();
   bfs.pop();
   if (vis[s]) continue;
   vis[s] = true;
   for(int i = 0; i < adjl[s].size(); i++){
     int t = adjl[s][i];
     if (t == 0) mog = true;
     if (!vis[t]) bfs.push(t);
   }
  }
  if (mog) cout <<"1";
  else cout << "0";
  for (int i = 1; i < n; i++){
    if (vis[i]) cout << "1";
    else cout << "0";
  }
}

Compilation message

wand.cpp: In function 'int main()':
wand.cpp:26:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i = 0; i < adjl[s].size(); i++){
                   ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 115 ms 5496 KB Output is correct
4 Correct 115 ms 5496 KB Output is correct
5 Correct 116 ms 5496 KB Output is correct
6 Correct 126 ms 5540 KB Output is correct
7 Correct 114 ms 5336 KB Output is correct
8 Correct 121 ms 5612 KB Output is correct
9 Incorrect 126 ms 5804 KB Output isn't correct
10 Correct 134 ms 5956 KB Output is correct