Submission #1068356

# Submission time Handle Problem Language Result Execution time Memory
1068356 2024-08-21T09:27:06 Z edogawa_something Toy Train (IOI17_train) C++17
0 / 100
2000 ms 1920 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;
bool vis[5001],viss[5001],visss[5001];
void dfs(ll x) {
  if(vis[x])
    return;
  vis[x]=1;
  for(auto it:adj[x]) {
    if(!r[it])
    dfs(it);
  }
}
void rdfs(ll x) {
  if(viss[x])
    return;
  viss[x]=1;
  for(auto it:radj[x]) {
    if(!r[it])
    rdfs(it);
  }
}
void realrdfs(ll x) {
  if(visss[x])
    return;
  visss[x]=1;
  for(auto it:radj[x])
    realrdfs(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(auto &it:ans)
    it=1;
  for(int i=0;i<a.size();i++) {
    if(r[i]==0) {
      for(int j=0;j<a.size();j++)
        vis[j]=viss[j]=visss[j]=0;
      dfs(i);
      rdfs(i);
      realrdfs(i);
      for(auto it:adj[i]) {
        if(it==i)
          chk[i]=1;
      }
      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]&=(1-visss[i]);
        }
      }
    }
  }
  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:44:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int i=0;i<u.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<a.size();i++) {
      |               ~^~~~~~~~~
train.cpp:50:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |       for(int j=0;j<a.size();j++)
      |                   ~^~~~~~~~~
train.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |       for(int j=0;j<a.size();j++) {
      |                   ~^~~~~~~~~
train.cpp:66:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         for(int j=0;j<a.size();j++) {
      |                     ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 1264 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 447 ms 1920 KB Output is correct
2 Correct 279 ms 1628 KB Output is correct
3 Correct 162 ms 1828 KB Output is correct
4 Incorrect 1732 ms 1848 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 1628 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2068 ms 1636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 1264 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -