Submission #107564

#TimeUsernameProblemLanguageResultExecution timeMemory
107564patrikpavic2Three Friends (BOI14_friends)C++17
100 / 100
69 ms6136 KiB
#include <cstdio> #include <cstring> #include <cstdlib> #include <ctime> #include <algorithm> #include <set> #include <vector> #include <queue> #include <map> #define X first #define Y second #define PB push_back using namespace std; typedef long long ll; typedef long double ld; typedef pair < int, int > pii; typedef vector < int > vi; typedef set < int > si; const int N = 1e5 + 500; const int M = 1e6 + 500; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const int OFF = (1 << 18); const int LOG = 20; const double EPS = 1e-9; const double PI = 3.1415926535; char s[2 * M], ans[2 * M]; int cnt, n, can = 0; int main(){ scanf("%d", &n); if(n % 2 == 0){ printf("NOT POSSIBLE\n"); return 0; } scanf("%s", s); int j = n / 2; for(int i = 0;2 * i + 1 < n;i++,j++){ if(s[i] != s[j]) cnt++,i--; if(cnt > 1) break; } if(cnt <= 1){ for(int i = 0;2 * i + 1 < n;i++) ans[i] = s[i]; can++; } cnt = 0;j = 0; for(int i = n / 2 + 1;i < n;i++,j++){ if(s[i] != s[j]) cnt++,i--; if(cnt > 1) break; } if(cnt <= 1){ for(int i = n / 2 + 1;i < n;i++){ if(ans[i - n / 2 - 1] != s[i] && can){ printf("NOT UNIQUE\n"); return 0; } ans[i - n / 2 - 1] = s[i]; } can++; } if(!can) printf("NOT POSSIBLE\n"); else{ for(int i = 0;2 * i + 1 < n;i++) printf("%c", ans[i]); printf("\n"); } return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
friends.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s);
     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...