Submission #69340

#TimeUsernameProblemLanguageResultExecution timeMemory
69340IvanCAmusement Park (JOI17_amusement_park)C++17
78 / 100
77 ms46152 KiB
#include "Joi.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 10011; const int MOD = 60; static vector<int> grafo[MAXN],digitos; static int dfs_num[MAXN],dfsCount; static void dfs(int v){ dfs_num[v] = dfsCount % MOD; dfsCount++; for(int u : grafo[v]){ if(dfs_num[u] != -1) continue; dfs(u); } } void Joi(int N, int M, int A[], int B[], long long X, int T){ memset(dfs_num,-1,sizeof(dfs_num)); dfsCount = 0; for(int i = 0;i<N;i++) grafo[i].clear(); digitos.clear(); for(int i = 0;i<MOD;i++){ if((1LL << i) & X) digitos.push_back(1); else digitos.push_back(0); } for(int i = 0;i<M;i++){ grafo[A[i]].push_back(B[i]); grafo[B[i]].push_back(A[i]); } dfs(0); for(int i = 0; i < N; i++){ MessageBoard(i, digitos[dfs_num[i]]); } }
#include "Ioi.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 10011; const int MOD = 60; static deque<int> grafo[MAXN],tree[MAXN]; static int digitos[MOD],freq[MOD],distintos,processado[MAXN],dfsCount,dfs_num[MAXN],qual_digito[MAXN],pai[MAXN]; static void add_number(int x){ if(freq[x] == 0) distintos++; freq[x]++; } static void add_vertex(int v){ digitos[dfs_num[v]] = qual_digito[v]; add_number(dfs_num[v]); } static void dfs(int v){ dfs_num[v] = dfsCount % MOD; dfsCount++; for(int u : grafo[v]){ if(dfs_num[u] != -1) continue; pai[u] = v; tree[v].push_back(u); dfs(u); } } static void find_ans(int v,int st){ processado[v] = 1; add_vertex(v); if(distintos == MOD) return; while(st != -1 && tree[v].front() != st){ tree[v].push_back(tree[v].front()); tree[v].pop_front(); } for(int u : tree[v]){ if(distintos == MOD) return; if(processado[u]) continue; int davez = Move(u); qual_digito[u] = davez; find_ans(u,-1); if(distintos == MOD) return; Move(v); } if(distintos != MOD){ int davez = Move(pai[v]); qual_digito[pai[v]] = davez; find_ans(pai[v],v); } } long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) { memset(dfs_num,-1,sizeof(dfs_num)); memset(processado,0,sizeof(processado)); memset(freq,0,sizeof(freq)); dfsCount = 0; distintos = 0; for(int i = 0;i<N;i++) grafo[i].clear(); for(int i = 0;i<M;i++){ grafo[A[i]].push_back(B[i]); grafo[B[i]].push_back(A[i]); } dfs(0); qual_digito[P] = V; find_ans(P,-1); long long ans = 0; for(int i = 0;i<MOD;i++) if(digitos[i]) ans += (1LL << i); return ans; }
#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...