Submission #426553

# Submission time Handle Problem Language Result Execution time Memory
426553 2021-06-14T06:34:06 Z Rouge_Hugo Toy Train (IOI17_train) C++14
0 / 100
1283 ms 1584 KB
#include<bits/stdc++.h>
#include "train.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;int n,m;
vector<int>ans;
const int N=5090;
int vis[N],yes[N];int o;
vector<int>v[N];
int rr[N];
void d(int x)
{
    if(rr[x])return;
    if(x==o&&vis[x])yes[x]=1;
    if(vis[x])return;
    vis[x]=1;
    for(auto it:v[x])
    {
        if(rr[it])continue;
        d(it);
    }
}
int dfs(int x)
{
   if(vis[x])return 0;
   if(yes[x])return 1;
   vis[x]=1;int z=0;
   for(auto it:v[x])
   {
       z=max(z,dfs(it));
   }
   return z;
}

vector<int> who_wins(vector<int> A,vector<int> r,vector<int> u,vector<int> uu) {
	n=r.size();m=u.size();
	for(int i=0;i<n;i++)
        rr[i]=r[i];
    for(int i=0;i<m;i++)
        v[u[i]].pb(uu[i]);

	for(int i=0;i<n;i++)
    {
        if(rr[i])continue;
        memset(vis,0,sizeof vis);
        o=i;
        d(i);
    }
    for(int i=0;i<n;i++)
    {
        memset(vis,0,sizeof vis);
        ans.pb(dfs(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:41:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   41 |     for(int i=0;i<m;i++)
      |     ^~~
train.cpp:44:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |  for(int i=0;i<n;i++)
      |  ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 844 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 1584 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 813 ms 1200 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 Incorrect 1283 ms 1452 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 844 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -