답안 #295771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
295771 2020-09-09T22:56:45 Z DanerZein 장난감 기차 (IOI17_train) C++14
0 / 100
1727 ms 262148 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
vector<vi> G;
bitset<5010> ab,cs;
int vis[5010];
vi res;
bool dfs(int u){
  vis[u]=2;
  if(ab[u]==1){
    int x=-1;
    for(auto &v:G[u]){
      if(v==u and cs[v]==1){
	res[u]=1;
	return 1;
      }
      else{
	if(v!=u) x=v;
      }
    }
    if(x!=-1) return res[u]=dfs(x);
    return 0;
  }
  else{
    int x=-1;
    for(auto &v:G[u]){
      if(v==u and cs[v]==0){
	res[u]=0;
	return 0;
      }
      else{
	if(v!=u) x=v;
      }
    }
    if(x!=-1) return res[u]=dfs(x);
    return 1;
  }
}
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
  for(int i=0;i<a.size();i++){
    ab[i]=a[i];
    cs[i]=r[i];
  }
  int n=a.size();
  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);
  }
  memset(vis,-1,sizeof vis);
  for(int i=0;i<a.size();i++){
    if(vis[i]==-1){
      dfs(i);
    }
  }
  return res;
}

Compilation message

train.cpp: In function 'bool dfs(int)':
train.cpp:22:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |     if(x!=-1) return res[u]=dfs(x);
train.cpp:36:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   36 |     if(x!=-1) return res[u]=dfs(x);
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(int i=0;i<a.size();i++){
      |               ~^~~~~~~~~
train.cpp:48:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for(int i=0;i<u.size();i++){
      |               ~^~~~~~~~~
train.cpp:54:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for(int i=0;i<a.size();i++){
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 247 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 260 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1727 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 262 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 302 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 247 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -