# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830142 | 2023-08-18T19:59:41 Z | FEDIKUS | Amusement Park (JOI17_amusement_park) | C++17 | 20 ms | 5200 KB |
#include "Joi.h" #include<bits/stdc++.h> using namespace std; using ll = long long; namespace{ const int maxn=10010; const int logg=60; int boja[maxn]; int bio[maxn]; int p[maxn]; vector<int> g[maxn]; vector<int> stablo[maxn]; int deg[maxn]; set<int> lisce; int klk=0; bool dfs(int node){ bio[node]=1; klk++; boja[node]=klk-1; if(klk==60) return true; for(int i:g[node]){ if(bio[i]) continue; stablo[node].push_back(i); p[i]=node; if(dfs(i)) return true; } return false; } void dfs2(int node){ bio[node]=2; for(int i:g[node]){ if(bio[i]==1){ p[node]=i; p[i]=-1; dfs2(i); p[node]=-1; p[i]=node; }else if(bio[i]==0){ int uzimam=-1; if(*lisce.begin()==node){ uzimam=*(++lisce.begin()); }else uzimam=*lisce.begin(); boja[i]=boja[uzimam]; p[node]=i; p[i]=-1; deg[p[uzimam]]--; deg[uzimam]--; lisce.erase(uzimam); if(deg[p[uzimam]]==1) lisce.emplace(p[uzimam]); lisce.emplace(i); if(deg[node]==1) lisce.erase(node); deg[node]++; deg[i]++; if(deg[i]==1) lisce.emplace(i); dfs2(i); if(deg[i]==1) lisce.erase(i); deg[node]--; deg[i]--; if(deg[node]==1) lisce.emplace(node); lisce.erase(i); if(deg[p[uzimam]]==1) lisce.erase(p[uzimam]); lisce.emplace(uzimam); deg[uzimam]++; deg[p[uzimam]]++; p[node]=-1; p[i]=node; } } } } void Joi(int n, int m, int a[], int b[], ll x, int t) { for(int i=0;i<m;i++){ g[a[i]].push_back(b[i]); g[b[i]].push_back(a[i]); } p[0]=-1; dfs(0); for(int i=0;i<n;i++) if(bio[i]==1) for(int j:stablo[i]) deg[i]++,deg[j]++; for(int i=0;i<n;i++) if(bio[i]==1 && deg[i]==1) lisce.emplace(i); dfs2(0); for(int i=0;i<n;i++) MessageBoard(i,((1LL<<boja[i])&x)!=0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 1544 KB | Do not print anything on standard output. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 4896 KB | Do not print anything on standard output. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 1536 KB | Do not print anything on standard output. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 5200 KB | Do not print anything on standard output. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 20 ms | 4940 KB | Do not print anything on standard output. |
2 | Halted | 0 ms | 0 KB | - |