제출 #879530

#제출 시각아이디문제언어결과실행 시간메모리
879530ThylOne세 명의 친구들 (BOI14_friends)C++14
0 / 100
51 ms24160 KiB
#include<bits/stdc++.h> using namespace std; const int maxiN=200001; const int LOG = 21; int n,L; string ans; int nbSolLU(string lower,string upper,int b=0){ bool comp[L][2]; for(int i=0;i<L;i++){ comp[i][0] = (upper[i]==lower[i]); comp[i][1] = (upper[i+1]==lower[i]); } int prefix[L]; int suffix[L]; int actSum=0; for(int i=0;i<L;i++){ actSum+=comp[i][0]; prefix[i] = actSum; } actSum=0; for(int i=L-1;i>=0;i--){ actSum+=comp[i][1]; suffix[i] = actSum; } int nbSol=0; for(int i=b;i<L+1;i++){ int pts = 0; if(i>0)pts+=prefix[i-1]; if(i<L-1)pts+=suffix[i]; if(pts==L){ if(ans==""){ for(int j=0;j<L+1;j++){ if(j!=i)ans+=upper[j]; } } nbSol++; } } return nbSol; } signed main(){ n;cin>>n; if(n%2==0){ cout<<"NOT POSSIBLE\n"; return 0; } L = (n-1)/2; string line;cin>>line; string upper=""; string lower=""; for(int i=0;i<=L;i++){ upper+=line[i]; } for(int i=L+1;i<n;i++){ lower+=line[i]; } int nbSol=0; nbSol+=nbSolLU(lower,upper); upper=""; lower=""; for(int i=L;i<n;i++){ upper+=line[i]; } for(int i=0;i<L;i++){ lower+=line[i]; } nbSol+=nbSolLU(lower,upper,1); if(nbSol==1){ cout<<ans<<endl; }else if(nbSol==0){ cout<<"NOT POSSIBLE"<<endl; }else{ cout<<"NOT UNIQUE"<<endl; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp: In function 'int main()':
friends.cpp:43:5: warning: statement has no effect [-Wunused-value]
   43 |     n;cin>>n;
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...