Submission #448664

#TimeUsernameProblemLanguageResultExecution timeMemory
448664vanicQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++14
100 / 100
3655 ms24064 KiB
#include <vector> #include <algorithm> using namespace std; int fact[13]; void precompute(){ fact[0]=1; for(int i=1; i<13; i++){ fact[i]=fact[i-1]*i; } } int povrh(int a, int b){ return fact[a]/(fact[b]*fact[a-b]); } vector < int > radi(int x){ vector < int > v; int ost=6; for(int i=1; i<=12; i++){ if(!ost){ break; } if(x>=povrh(12-i, ost-1)){ x-=povrh(12-i, ost-1); } else{ v.push_back(i); ost--; } } return v; } int encode (int n, int x, int y) { precompute(); vector < int > s1, s2; s1=radi(x); s2=radi(y); while(!s2.empty()){ if(find(s1.begin(), s1.end(), s2.back())!=s1.end()){ s1.erase(find(s1.begin(), s1.end(), s2.back())); } s2.pop_back(); } return s1.back(); }
#include <vector> #include <algorithm> using namespace std; int fact[13]; void precompute(){ fact[0]=1; for(int i=1; i<13; i++){ fact[i]=fact[i-1]*i; } } int povrh(int a, int b){ return fact[a]/(fact[b]*fact[a-b]); } vector < int > radi(int x){ vector < int > v; int ost=6; for(int i=1; i<=12; i++){ if(!ost){ break; } if(x>=povrh(12-i, ost-1)){ x-=povrh(12-i, ost-1); } else{ v.push_back(i); ost--; } } return v; } int decode (int n, int q, int h) { precompute(); vector < int > s1=radi(q); if(find(s1.begin(), s1.end(), h)!=s1.end()){ return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...