제출 #105696

#제출 시각아이디문제언어결과실행 시간메모리
105696sams세 명의 친구들 (BOI14_friends)C++14
0 / 100
173 ms9816 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6+10; int n; char u[maxn]; string a, b, s1, s2; int main() { scanf("%d", &n); for(int i = 0 ; i < n ; ++i) scanf(" %c", &u[i]); if(n%2 == 0) { printf("NOT POSSIBLE\n"); return 0; } int mid = (n-1)/2, p1 = -1, p2 = -1; bool ok1 = true, ok2 = true; for(int i = 0 ; i < mid ; ++i) a.push_back(u[i]); for(int i = mid ; i < n ; ++i) b.push_back(u[i]); for(int i = 0, j = 0; i < mid ; ++j, ++i) { if(a[i] != b[j]) { if(p1 == -1 && a[i] == b[++j]) p1 = j; else { ok1 = false; break; } } s1 += a[i]; } a.clear(); b.clear(); for(int i = 0 ; i <= mid ; ++i) b.push_back(u[i]); for(int i = mid + 1 ; i < n ; ++i) a.push_back(u[i]); for(int i = 0, j = 0; i < mid ; ++j, ++i) { if(a[i] != b[j]) { if(p2 == -1 && a[i] == b[++j]) p2 = j; else { ok2 = false; break; } } s2 += a[i]; } if(!ok1 && !ok2) printf("NOT POSSIBLE\n"); else { if(ok1 && ok2 && s1 != s2) printf("NOT UNIQUE"); else if(ok1) for(int i = 0 ; i < s1.size() ; ++i) printf(" %c", s1[i]); else for(int i = 0 ; i < s2.size() ; ++i) printf(" %c", s2[i]); printf("\n"); } return 0; }

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

friends.cpp: In function 'int main()':
friends.cpp:63:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   else if(ok1) for(int i = 0 ; i < s1.size() ; ++i) printf(" %c", s1[i]);
                                ~~^~~~~~~~~~~
friends.cpp:64:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   else for(int i = 0 ; i < s2.size() ; ++i) printf(" %c", s2[i]);
                        ~~^~~~~~~~~~~
friends.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
friends.cpp:14:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0 ; i < n ; ++i) scanf(" %c", &u[i]);
                               ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...