제출 #931618

#제출 시각아이디문제언어결과실행 시간메모리
931618penguin133세 명의 친구들 (BOI14_friends)C++17
0 / 100
22 ms5420 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; string s; void solve(){ cin >> n; if(n % 2 == 0){ cout << "NOT POSSIBLE\n"; return; } cin >> s; int a = 0, b = 0, c = 0, d = 0; for(int i = 0; i < n / 2; i++){ if(s[i] == s[i + n / 2])a++; else break; } for(int i = 0; i < n / 2; i++){ if(s[i] == s[i + n / 2 + 1])b++; else break; } for(int i = n - 1; i >= n / 2 + 1; i--){ if(s[i] == s[i - n / 2])c++; else break; } for(int i = n - 1; i >= n / 2 + 1; i--){ if(s[i] == s[i - n / 2 - 1])d++; else break; } if(max(b + c, a + d) > n / 2 || (b + c == n / 2 && a + d == n / 2))cout << "NOT UNIQUE\n"; else if(b + c < n / 2 && a + d < n / 2)cout << "NOT POSSIBLE\n"; else{ if(a + d == n / 2){ for(int i = 0; i < n / 2; i++)cout << s[i]; } else{ for(int i = n / 2 + 1; i < n; i++)cout << s[i]; } } } main(){ ios::sync_with_stdio(0);cin.tie(0); int tc = 1; //cin >> tc; for(int tc1=1;tc1<=tc;tc1++){ // cout << "Case #" << tc1 << ": "; solve(); } }

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

friends.cpp:53:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   53 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...