답안 #422184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422184 2021-06-09T20:30:52 Z Antekb 장난감 기차 (IOI17_train) C++14
28 / 100
223 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]);
	}
	//int wsk=n-1;
	int ile=0;
	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;//cout<<j;
			//cout<<"\n";
			for(int j=0; j<V.size(); j++){
				int v=V[j];
				for(int u:rE[v]){
					if(a[u] && !vis[u] && !usun[u]){
						vis[u]=1;
						V.pb(u);
					}
					if(!a[u] && --d[u]==0 && !vis[u] && !usun[u]){
						vis[u]=1;
						V.pb(u);
					}
				}
			}
			//for(int i:V)cout<<i<<" ";
			//cout<<" q\n";
			if(V.size()==n-ile)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] && !usun[u]){
						vis[u]=1;
						V.pb(u);
					}
					if(a[u] && --d[u]==0 && !vis[u] && !usun[u]){
						vis[u]=1;
						V.pb(u);
					}
				}
			}
			for(int i:V)usun[i]=1;
			//for(int i:V)cout<<i<<" ";
			//cout<<"\n";
			ile=0;
			for(int i=0; i<n; i++)ile+=usun[i];
	}
	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:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
train.cpp:44:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |    if(V.size()==n-ile)break;
      |       ~~~~~~~~^~~~~~~
train.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |    for(int j=0; j<V.size(); j++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1484 KB Output is correct
2 Correct 7 ms 1424 KB Output is correct
3 Correct 6 ms 1484 KB Output is correct
4 Correct 6 ms 1484 KB Output is correct
5 Correct 6 ms 1484 KB Output is correct
6 Correct 6 ms 1356 KB Output is correct
7 Correct 5 ms 1484 KB Output is correct
8 Correct 6 ms 1452 KB Output is correct
9 Correct 5 ms 1356 KB Output is correct
10 Correct 5 ms 1356 KB Output is correct
11 Correct 4 ms 1420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Incorrect 1 ms 716 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 1936 KB Output is correct
2 Correct 175 ms 1944 KB Output is correct
3 Correct 223 ms 1868 KB Output is correct
4 Correct 12 ms 1812 KB Output is correct
5 Incorrect 10 ms 1868 KB 3rd lines differ - on the 11th token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1612 KB Output is correct
2 Correct 9 ms 1680 KB Output is correct
3 Correct 9 ms 1868 KB Output is correct
4 Correct 9 ms 1868 KB Output is correct
5 Correct 9 ms 1808 KB Output is correct
6 Correct 9 ms 1868 KB Output is correct
7 Correct 9 ms 1804 KB Output is correct
8 Correct 10 ms 1740 KB Output is correct
9 Correct 9 ms 1740 KB Output is correct
10 Correct 9 ms 1896 KB Output is correct
11 Correct 12 ms 1868 KB Output is correct
12 Correct 12 ms 1808 KB Output is correct
13 Correct 13 ms 1812 KB Output is correct
14 Correct 12 ms 1708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1868 KB Output is correct
2 Correct 9 ms 1740 KB Output is correct
3 Correct 10 ms 1820 KB Output is correct
4 Correct 8 ms 1740 KB Output is correct
5 Correct 1 ms 844 KB Output is correct
6 Correct 5 ms 1316 KB Output is correct
7 Correct 6 ms 1420 KB Output is correct
8 Correct 6 ms 1432 KB Output is correct
9 Correct 8 ms 1484 KB Output is correct
10 Correct 2 ms 972 KB Output is correct
11 Correct 6 ms 1356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1484 KB Output is correct
2 Correct 7 ms 1424 KB Output is correct
3 Correct 6 ms 1484 KB Output is correct
4 Correct 6 ms 1484 KB Output is correct
5 Correct 6 ms 1484 KB Output is correct
6 Correct 6 ms 1356 KB Output is correct
7 Correct 5 ms 1484 KB Output is correct
8 Correct 6 ms 1452 KB Output is correct
9 Correct 5 ms 1356 KB Output is correct
10 Correct 5 ms 1356 KB Output is correct
11 Correct 4 ms 1420 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 716 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 1 ms 716 KB Output is correct
19 Incorrect 1 ms 716 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
20 Halted 0 ms 0 KB -