답안 #426470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426470 2021-06-14T04:39:58 Z jeqcho 장난감 기차 (IOI17_train) C++17
0 / 100
8 ms 1392 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define F0R(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define R0F(i,b) ROF(i,0,b)
#define all(x) begin(x),end(x)
#define sz(x) int(x.size())
#define pb push_back
#define rsz resize
#define trav(a,x) for(auto&a :x)
#define fi first
#define se second

int const N=5e3+3;
vi to[N];
vi tor[N];
vi r;
int n;
bitset<N> vis;
stack<int> s;
vi topsort;

void dfs(int now)
{
	if(vis[now])return;
	vis[now]=1;
	trav(chi,to[now])
	{
		dfs(chi);
	}
	s.push(now);
}

void dfs2(int now)
{
	if(vis[now])return;
	vis[now]=1;
	trav(chi,tor[now])
	{
		dfs2(chi);
	}
	topsort.pb(now);
}

void kos()
{
	F0R(i,n)
	{
		dfs(i);
	}
	vis.reset();
	while(!s.empty())
	{
		int u=s.top();
		s.pop();
		dfs2(u);
	}
	reverse(all(topsort));
}

vi who_wins(vi a, vi r1, vi u, vi v) {
	n=sz(a);
	r=r1;
	F0R(i,n)
	{
		to[u[i]].pb(v[i]);
		tor[v[i]].pb(u[i]);
	}
	kos();
	bool ok=0;
	vi ans(n,1);
	//R0F(i,n)
	//{
		//if(r[topsort[i]])
		//{
			//ok=1;
		//}
		//ans[topsort[i]]=ok;
	//}
	return ans;
}

Compilation message

train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:79:7: warning: unused variable 'ok' [-Wunused-variable]
   79 |  bool ok=0;
      |       ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 972 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 1392 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1100 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1100 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 972 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -