답안 #422168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422168 2021-06-09T20:11:52 Z Antekb 장난감 기차 (IOI17_train) C++14
0 / 100
2000 ms 1944 KB
#include "train.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb(x) push_back(x)
using namespace std;
const int N=5005;
vector<int> E[N], rE[N], E2[N], rE2[N];
int d[N];
int wsk=0;
int czy[N][N], dobre[N], petla[N];
int vis[N];
int usun[N];
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> uu, std::vector<int> vv) {
	int n=a.size(), m=uu.size();
	std::vector<int> res(n);
	for(int i=0; i<m; i++){
		//cout<<uu[i]<<" "<<vv[i]<<"\n";
		E[uu[i]].pb(vv[i]);
		rE[vv[i]].pb(uu[i]);
	}
	while(true){
			vector<int> V;
			for(int j=0; j<n; j++)if(!usun[j])d[j]=E[j].size(), vis[j]=0;
			for(int j=0; j<n; j++)if(r[j] || usun[j])V.pb(j), vis[j]=1;
			for(int j=0; j<V.size(); j++){
				int v=V[j];
				for(int u:rE[v]){
					if(a[u] && !vis[u]){
						vis[u]=1;
						V.pb(u);
					}
					if(!a[u] && --d[u]==0 && !vis[u]){
						V.pb(u);
					}
				}
			}
			//for(int i:V)cout<<i<<" ";
			//cout<<" q\n";
			if(V.size()==n)break;
			V.clear();
			for(int j=0; j<n; j++){
				if(!vis[j] || usun[j]){
					vis[j]=1;
					V.pb(j);
				}
				else{
					vis[j]=0;
					d[j]=E[j].size();
				}
			}
			for(int j=0; j<V.size(); j++){
				int v=V[j];
				for(int u:rE[v]){
					if(!a[u] && !vis[u]){
						vis[u]=1;
						V.pb(u);
					}
					if(a[u] && --d[u]==0){
						V.pb(u);
					}
				}
			}
			//for(int i:V)usun[i]=1, cout<<i<<" ";
			//cout<<"\n";
	}
	for(int i=0; i<n; i++)res[i]=!usun[i];
	return res;
}

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:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
train.cpp:40:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |    if(V.size()==n)break;
      |       ~~~~~~~~^~~
train.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2085 ms 1356 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2084 ms 716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 1944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2074 ms 1596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2079 ms 1868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2085 ms 1356 KB Time limit exceeded
2 Halted 0 ms 0 KB -