Submission #148626

#TimeUsernameProblemLanguageResultExecution timeMemory
148626본인 방금 올솔하는 상상함 (#200)List of Unique Integers (FXCUP4_unique)C++17
100 / 100
6 ms640 KiB
#include "unique.h" int dp[220][220]; int ask(int s, int e){ if(dp[s][e]!=-1) return dp[s][e]; return dp[s][e]=UniqueCount(s,e); } std::vector<int> PickUnique(int N) { std::vector<int> ret(N); for(int i=0;i<N;i++){ for(int j=0;j<N;j++) dp[i][j]=-1; } for(int i=0;i<N;i++){ if(i==0){ int a = ask(1,N-1); int b = ask(0,N-1); if(a+1==b) ret[i]=1; } else if(i==N-1){ int a = ask(0,N-2); int b = ask(0,N-1); if(a+1==b) ret[i]=1; } else{ int a = ask(0,i-1); int aa = ask(0,i); int b = ask(i+1,N-1); int bb = ask(i,N-1); if(a+1==aa&&b+1==bb) ret[i]=1; } } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...