답안 #1068284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068284 2024-08-21T09:05:56 Z edogawa_something 장난감 기차 (IOI17_train) C++17
0 / 100
654 ms 1884 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vii;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
vii adj[5001],radj[5001];
vector<int>a,r,answer;
bool vis[5001],viss[5001];
void dfs(ll x) {
  if(vis[x])
    return;
  vis[x]=1;
  for(auto it:adj[x])
    dfs(it);
}
void rdfs(ll x) {
  if(viss[x])
    return;
  viss[x]=1;
  for(auto it:radj[x])
    rdfs(it);
}
bool chk[5001];
vector<int>ans;
vector<int> who_wins(std::vector<int> A, std::vector<int> R, std::vector<int> u, std::vector<int> v) {
  a=A,r=R;
  ans.resize(a.size());
  for(int i=0;i<u.size();i++)
    adj[u[i]].pb(v[i]),radj[v[i]].pb(u[i]);
  for(int i=0;i<a.size();i++) {
    for(int j=0;j<a.size();j++)
      vis[j]=0;
    if(r[i]) {
      for(auto it:adj[i]) {
        if(it==i)
          chk[i]=1;
      }
      dfs(i),rdfs(i);
      for(int j=0;j<a.size();j++) {
        if(j==i)
          continue;
        if(vis[j]&&viss[j])
          chk[i]=1;
      }
      if(chk[i]) {
        for(int j=0;j<a.size();j++)
          ans[j]|=(viss[j]);
      }
    }
  }
  return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:33:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int i=0;i<u.size();i++)
      |               ~^~~~~~~~~
train.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i=0;i<a.size();i++) {
      |               ~^~~~~~~~~
train.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int j=0;j<a.size();j++)
      |                 ~^~~~~~~~~
train.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |       for(int j=0;j<a.size();j++) {
      |                   ~^~~~~~~~~
train.cpp:51:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for(int j=0;j<a.size();j++)
      |                     ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 1344 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 1884 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 654 ms 1624 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1624 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 1344 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -