Submission #485492

# Submission time Handle Problem Language Result Execution time Memory
485492 2021-11-08T01:58:26 Z PedroBigMan Toy Train (IOI17_train) C++14
0 / 100
6 ms 1060 KB
#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 "train.h"
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 100000000000000000LL
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
unordered_map<ll,ll> m; ll N,M; vector<ll> p3; ll e; ll mai; vector<vector<ll> > adj; ll typ; vector<ll> a,r;

void f(ll s)
{
	if(m.find(s)!=m.end()) {return;}
	e=s%N; mai=s/N;
	vector<ll> nxt;
	REP(i,0,adj[s].size())
	{
		typ=(mai/p3[adj[s][i]])%3;
		if(typ==1 && a[e]==1) {m[s]=1; return;}
		else if(typ==2 && a[e]==0) {m[s]=0; return;}
		else if(typ==0) 
		{
			if(r[adj[s][i]]==0) {nxt.pb((mai+2*p3[adj[s][i]])*N+adj[s][i]);}
			else 
			{
				ll newmai=mai + p3[adj[s][i]]; 
				REP(j,0,N) 
				{
					if((mai/p3[j])%3==2) {newmai-=p3[j];}
				}
				nxt.pb(newmai*N+adj[s][i]);
			}
		}
	}
	REP(i,0,nxt.size()) 
	{
		f(nxt[i]);
		if(a[e]==m[nxt[i]]) {m[s]=m[nxt[i]]; return;}
	}
	m[s]=1-a[e]; return;
}

vector<int> who_wins(vector<int> aa, vector<int> rr, vector<int> u, vector<int> v) 
{
	a=aa; r=rr;
	N=a.size(); M=u.size(); REP(i,0,N) {adj.pb({});} 
	REP(i,0,M) {adj[u[i]].pb(v[i]);}
	ll curpow=1; REP(i,0,N+1) {p3.pb(curpow); curpow*=3;}
	return {};
	vector<ll> ans; REP(i,0,N) {f(N*p3[i]+i); ans.pb(m[N*p3[i]+i]);}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 792 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1060 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 908 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1036 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 792 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -