Submission #495491

# Submission time Handle Problem Language Result Execution time Memory
495491 2021-12-19T02:29:18 Z PedroBigMan Toy Train (IOI17_train) C++14
12 / 100
95 ms 1300 KB
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
#define VV(vvvv,NNNN,xxxx); REP(i,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007LL;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

vector<int> who_wins(vector<int> aa, vector<int> rr, vector<int> u, vector<int> v) 
{
	vector<ll> a=aa; vector<ll> r=rr; vector<vector<ll> > adj;
	ll N=a.size(); ll M=u.size(); REP(i,0,N+1) {adj.pb({});} ll S; REP(i,0,N) {if(r[i]==1) {S=i;}}
	REP(i,0,M) 
	{
		if(v[i]==S) {v[i]=N;}
		adj[u[i]].pb(v[i]);
	}
	adj[N].pb(S); vector<bool> in; VV(in,N+1,false); in[N]=true;
	while(1>0)
	{
		bool ok=false;
		REP(i,0,N)
		{
			if(in[i]) {continue;}
			if(a[i]==1)
			{
				REP(j,0,adj[i].size()) {if(in[adj[i][j]]) {in[i]=true; ok=true; break;}}
			}
			else
			{
				bool all=true; REP(j,0,adj[i].size()) {if(!in[adj[i][j]]) {all=false; break;}}
				if(all) {in[i]=true; ok=true;}
			}
		}
		if(!ok) {break;}
	}
	vector<ll> ans; VV(ans,N,0LL);
	if(!in[S]) {return ans;}
	REP(i,0,N) {if(in[i]) {ans[i]=1;}}
	return ans;
}

Compilation message

train.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("O3")
      | 
train.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("unroll-loops")
      |
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 912 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 1 ms 292 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 89 ms 1292 KB Output is correct
2 Correct 95 ms 1288 KB Output is correct
3 Correct 76 ms 1292 KB Output is correct
4 Correct 7 ms 1300 KB Output is correct
5 Correct 7 ms 1256 KB Output is correct
6 Incorrect 7 ms 1248 KB 3rd lines differ - on the 47th token, expected: '1', found: '0'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1036 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 Correct 8 ms 1260 KB Output is correct
2 Correct 6 ms 1288 KB Output is correct
3 Correct 7 ms 1296 KB Output is correct
4 Correct 7 ms 1196 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 5 ms 912 KB Output is correct
7 Correct 4 ms 848 KB Output is correct
8 Correct 5 ms 880 KB Output is correct
9 Correct 5 ms 848 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 5 ms 816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 912 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -