Submission #495326

#TimeUsernameProblemLanguageResultExecution timeMemory
495326PedroBigManToy Train (IOI17_train)C++14
0 / 100
7 ms2192 KiB
/* 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);}} 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[e].size()) { typ=(mai/p3[adj[e][i]])%3; if(typ==2 && a[e]==0) {m[s]=0; return;} else if(typ==1 && a[e]==1) {m[s]=1; return;} else if(typ==0) { if(r[adj[e][i]]==0) {nxt.pb((mai+2*p3[adj[e][i]])*N+adj[e][i]);} else { ll newmai=mai + p3[adj[e][i]]; REP(j,0,N) { if((mai/p3[j])%3==2) {newmai-=p3[j];} } nxt.pb(newmai*N+adj[e][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,16) {p3.pb(curpow); curpow*=3;} vector<ll> ans; DEBUG(0); REP(i,0,N) {if(r[i]==0) {f(2*p3[i]*N+i); ans.pb(m[2*p3[i]*N+i]);} else {f(p3[i]*N+i); ans.pb(m[p3[i]*N+i]);}} return ans; }

Compilation message (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...