Submission #701879

#TimeUsernameProblemLanguageResultExecution timeMemory
701879Darren0724The Potion of Great Power (CEOI20_potion)C++17
0 / 100
3034 ms101600 KiB
#pragma GCC optimize("Ofast","O3") #pragma GCC target("avx2") #include<bits/stdc++.h> using namespace std; int n; vector<int> h; struct cmp{ bool operator()(const int &a,const int &b)const{ if(h[a]==h[b]){ return a<b; } return h[a]<h[b]; } }; vector<unordered_map<int,vector<pair<int,int>>>> s; void init(int N, int D, int H[]) { n=N; h.resize(n); s.resize(n); for(int i=0;i<n;i++){ h[i]=H[i]; } } void curseChanges(int U, int A[], int B[]) { for(int i=1;i<=U;i++){ int a=A[i-1]; int b=B[i-1]; if(s[a].find(b)==s[a].end()||s[a][b].back().second==0){ s[a][b].push_back({i,1}); s[b][a].push_back({i,1}); } else{ s[a][b].push_back({i,0}); s[b][a].push_back({i,0}); } } } int question(int x, int y, int v) { int ans=1000000000; vector<int> a(2),b(2); for(pair<int,vector<pair<int,int>>> j:s[x]){ int tmp=(--upper_bound(j.second.begin(),j.second.end(),make_pair(v,10)))->second; if(tmp==1){ a[h[j.first]]=1; } } for(pair<int,vector<pair<int,int>>> j:s[y]){ int tmp=(--upper_bound(j.second.begin(),j.second.end(),make_pair(v,10)))->second; if(tmp==1){ b[h[j.first]]=1; } } if(a[0]==1&&b[0]==1){ return 0; } if(a[1]==1&&b[1]==1){ return 0; } if(a[0]==1&&b[1]==1){ return 1; } if(a[1]==1&&b[0]==1){ return 1; } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...