Submission #296816

# Submission time Handle Problem Language Result Execution time Memory
296816 2020-09-10T22:28:12 Z DanerZein Toy Train (IOI17_train) C++14
5 / 100
247 ms 262148 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
vector<vi> G;
bitset<5010> ab,cs,cl;
int vis[5010];
vi res,path;
int n;
bool dfs(int u){
  vis[u]=1;
  if(ab[u] and cs[u] and cl[u]){
    return res[u]=1;
  }
  if(!ab[u] and !cs[u] and cl[u]){
    return res[u]=0;
  }
  bool ans=0;
  for(auto &v:G[u]){
    ans=dfs(v);
  }
  if(G[u].size()==0){
    if(ab[u] and !cs[u]){
      ans=0;
    }
    if(!ab[u] and cs[u]){
      ans=1;
    }
  }
  return res[u]=ans;
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
  n=a.size();
  for(int i=0;i<a.size();i++){
    ab[i]=a[i];
    cs[i]=r[i];
  }
  G.resize(n+1);
  res.resize(n);
  for(int i=0;i<u.size();i++){
    int x=u[i],y=v[i];
    if(x!=y)
      G[x].push_back(y);
    if(x==y)
      cl[x]=1;
  }
  memset(vis,-1,sizeof vis);
  for(int i=0;i<n;i++){
    if(vis[i]==-1){
      res[i]=dfs(i);
    }
  }
  return res;
}

Compilation message

train.cpp: In function 'bool dfs(int)':
train.cpp:13:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   13 |     return res[u]=1;
train.cpp:16:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   16 |     return res[u]=0;
train.cpp:30:16: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   30 |   return res[u]=ans;
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:34:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int i=0;i<a.size();i++){
      |               ~^~~~~~~~~
train.cpp:40:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |   for(int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 5 ms 896 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
5 Correct 4 ms 896 KB Output is correct
6 Correct 4 ms 896 KB Output is correct
7 Correct 5 ms 896 KB Output is correct
8 Correct 4 ms 896 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 4 ms 896 KB Output is correct
11 Correct 4 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 168 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 247 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 177 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 173 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 5 ms 896 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
5 Correct 4 ms 896 KB Output is correct
6 Correct 4 ms 896 KB Output is correct
7 Correct 5 ms 896 KB Output is correct
8 Correct 4 ms 896 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 4 ms 896 KB Output is correct
11 Correct 4 ms 768 KB Output is correct
12 Runtime error 168 ms 262148 KB Execution killed with signal 9
13 Halted 0 ms 0 KB -