제출 #44306

#제출 시각아이디문제언어결과실행 시간메모리
44306rajarshi_basu세 명의 친구들 (BOI14_friends)C++14
0 / 100
121 ms9460 KiB
#include <iostream> #include <algorithm> #include <functional> #include <vector> #include <string> using namespace std; #define FOR(i,n) for(int i=0;i<n;i++) #define FORE(i,a,b) for(int i=a;i<=b;i++) #define vi vector<int> #define ii pair<int,int> #define mp(a,b) make_pair(a,b) #define null NULL; int main(){ int n; cin >> n; string s; cin >> s; int all[26]; FOR(i,26)all[i] = 0; FOR(i,n)all[s[i]-'A']++; int pos = -1; FOR(i,26){ if(all[i]%2 == 1){ if(pos == -1)pos = i; else{ cout<<"NOT POSSIBLE"<<endl; return 0; } } } string res; int ctr = 0; bool ok = false; int pp = -1; char cc = 'A' + pos; bool cs1 = false; //case 3. mid charac bool cs3 = false; { string ss = ""; FOR(i,n){ if(i==n/2)continue; ss+=s[i]; } //cout <<ss<<endl; string s1 = ""; FOR(i,n/2)s1+=ss[i]; s1+=s1; // cout<<s1<<endl; cs3 = (s1 == ss); if(cs3)res = s1; // cout<<"MC"<<cs3<<endl; } //cs4 somewhere else int cnt1 = 0; int cnt2 = 0; FOR(i,n/2){ if(s[i] == cc)cnt1++; if(s[i+n/2+1] == cc)cnt2++; } // cout << cnt1 << " " <<cnt2<<endl; bool kk1 =false;bool kk2 = false; if(cnt1 > cnt2){ string s1 = "";kk1= true; string s2 = ""; FOR(i,n/2+1){ s1+=s[i]; if(i!=n/2)s2+=s[i+n/2+1]; } // cout << s1<<" "<<s2 <<endl; int ptr1=0;int ptr2 = 0; bool ok1 = 0; FOR(i,n/2){ if(s1[i+ok1]!=s2[i]){ if(ok1){ kk1 = false; } } } if(kk1)res = s2; }else{ string s1 = ""; string s2 = ""; kk2= true; FOR(i,n/2+1){ if(i!=n/2)s1+=s[i]; s2+=s[i+n/2]; } bool ok1 = 0; FOR(i,n/2){ if(s1[i]!=s2[i+ok1]){ if(ok1){ kk2 = false; } } } if(kk2)res = s1; // cout << kk2 <<endl; } if((kk1 && kk2) || (kk1 && cs3) || (kk2 && cs3)){ cout << "NOT UNIQUE"<<endl; }else if(cs3 || kk1 || kk2){ cout<<res<<endl; }else{ cout << "NOT POSSIBLE"<<endl; } }

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

friends.cpp: In function 'int main()':
friends.cpp:82:9: warning: unused variable 'ptr1' [-Wunused-variable]
     int ptr1=0;int ptr2 = 0;
         ^~~~
friends.cpp:82:20: warning: unused variable 'ptr2' [-Wunused-variable]
     int ptr1=0;int ptr2 = 0;
                    ^~~~
friends.cpp:37:7: warning: unused variable 'ctr' [-Wunused-variable]
   int ctr = 0;
       ^~~
friends.cpp:38:8: warning: unused variable 'ok' [-Wunused-variable]
   bool ok = false;
        ^~
friends.cpp:39:7: warning: unused variable 'pp' [-Wunused-variable]
   int pp = -1;
       ^~
friends.cpp:41:8: warning: unused variable 'cs1' [-Wunused-variable]
   bool cs1 = false;
        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...