Submission #913805

#TimeUsernameProblemLanguageResultExecution timeMemory
913805Faisal_SaqibLast supper (IOI12_supper)C++17
61 / 100
235 ms15876 KiB
#pragma once #include "advisor.h" #include <vector> #include <cmath> #include <map> #include <set> using namespace std; /* 1 8 N≤5000 M=65000bits 2 9 N≤100000 M=2000000bits 3 9 N≤100000 M=1500bits K≤25000 4 35 N≤5000 M=10000bits 5 up to 39 N≤100000 M=1800000bits K≤25000 */ void ComputeAdvice(int *c, int n, int k, int m) { // cout<<"ASD\n"; vector<int> pos[n]; for(int j=0;j<n;j++) pos[j].push_back(1e9); for(int i=n-1;i>=0;i--) pos[c[i]].push_back(i); set<pair<int,int>> hap; map<int,int> color_to_index; vector<int> ap; for(int i=0;i<k;i++) { // cout<<"Hola "<<-pos[i].back()<<' '<<i<<endl; hap.insert({-pos[i].back(),i}); color_to_index[i]=i; ap.push_back(i); } int lg=log2(k); int last=-1; for(int j=0;j<n;j++) { if(color_to_index.find(c[j])==color_to_index.end()) { pos[c[j]].pop_back(); auto pt1=begin(hap); if(last!=-1 and pos[ap[last]].back()==(-1*(pt1->first))) pt1=hap.find({-pos[ap[last]].back(),ap[last]}); auto it=*pt1; hap.erase(pt1); int npd=color_to_index[it.second]; // cout<<"Rem "<<-it.first<<' '<<it.second<<" ind "; // cout<<npd<<endl; WriteAdvice((last==npd)); for(int l=lg;l>=0 and last!=npd;l--) { if(npd&(1ll<<l)) { WriteAdvice(1); } else { WriteAdvice(0); } } last=npd; color_to_index.erase(it.second); // cout<<"Adding "<<pos[c[j]].back()<<' '<<c[j]<<' '<<npd<<endl; hap.insert({-pos[c[j]].back(),c[j]}); color_to_index[c[j]]=npd; ap[npd]=c[j]; } else { hap.erase({-pos[c[j]].back(),c[j]}); pos[c[j]].pop_back(); hap.insert({-pos[c[j]].back(),c[j]}); } } }
#pragma once #include "assistant.h" #include <vector> #include <cmath> #include <map> #include <set> using namespace std; /* 1 8 N≤5000 M=65000bits 2 9 N≤100000 M=2000000bits 3 9 N≤100000 M=1500bits K≤25000 4 35 N≤5000 M=10000bits 5 up to 39 N≤100000 M=1800000bits K≤25000 */ void Assist(unsigned char *a, int n, int k, int r) { vector<int> ans; set<int> hap; for(int i=0;i<k;i++) { hap.insert(i); ans.push_back(i); } int lg=log2(k); int p=0; int last=-1; for(int j=0;j<n;j++) { int x=GetRequest(); if(hap.find(x)!=hap.end()) continue; int ind=0; int dop=a[p]; if(dop) ind=last; p++; for(int l=lg;l>=0 and dop==0;l--) { ind*=2; ind+=(a[p]); p++; } PutBack(ans[ind]); last=ind; hap.erase(ans[ind]); hap.insert(x); ans[ind]=x; } }

Compilation message (stderr)

advisor.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~

assistant.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...