답안 #296805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
296805 2020-09-10T22:06:57 Z DanerZein 장난감 기차 (IOI17_train) C++14
0 / 100
193 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]){
    if(v!=u) ans=dfs(v);
  }
  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];
    G[x].push_back(y);
    G[y].push_back(x);
    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:22:16: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |   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:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    for(int i=0;i<a.size();i++){
      |                ~^~~~~~~~~
train.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 192 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 182 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 188 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 193 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 187 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 192 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -