Submission #1111800

#TimeUsernameProblemLanguageResultExecution timeMemory
1111800ThegeekKnight16Three Friends (BOI14_friends)C++17
100 / 100
34 ms5564 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tam; cin >> tam; if (tam % 2 == 0) {cout << "NOT POSSIBLE" << '\n'; return 0;} int N = (tam-1)/2; string S; cin >> S; int resp = -1; vector<bool> sufEqual(N+2, 1); for (int i = N; i >= 1; i--) sufEqual[i] = (sufEqual[i+1] && S[i] == S[N+i]); bool pref = 1; for (int i = 0; i < N; i++) { if (pref && sufEqual[i+1]) resp = i; pref = pref && (S[i] == S[i+N+1]); } if (pref) resp = N; for (int i = N; i >= 1; i--) sufEqual[i] = (sufEqual[i+1] && S[N+i] == S[i-1]); pref = 1; int resp2 = -1; for (int i = 1; i <= N; i++) { pref = (pref && (S[i-1] == S[N+i-1])); if (pref && sufEqual[i+1]) resp2 = N+i; } if (resp == -1 && resp2 == -1) {cout << "NOT POSSIBLE" << '\n'; return 0;} else if (resp == -1) { for (int i = 0; i < N; i++) cout << S[i]; cout << '\n'; } else if (resp2 == -1 || resp == N) { for (int i = N+1; i < tam; i++) cout << S[i]; cout << '\n'; } else {cout << "NOT UNIQUE" << '\n'; return 0;} }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:35:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |         for (int i = 0; i < N; i++) cout << S[i]; cout << '\n';
      |         ^~~
friends.cpp:35:51: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   35 |         for (int i = 0; i < N; i++) cout << S[i]; cout << '\n';
      |                                                   ^~~~
friends.cpp:39:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   39 |         for (int i = N+1; i < tam; i++) cout << S[i]; cout << '\n';
      |         ^~~
friends.cpp:39:55: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   39 |         for (int i = N+1; i < tam; i++) cout << S[i]; cout << '\n';
      |                                                       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...