Submission #728761

#TimeUsernameProblemLanguageResultExecution timeMemory
728761rominanafuThree Friends (BOI14_friends)C++11
0 / 100
1081 ms6120 KiB
#include <bits/stdc++.h> using namespace std; int n, len; string s; string r1, r2; bool unico = true; bool posible(int x) { int ini = 0, fin = len; if (x < fin) fin++; while (ini <= len && fin < n) { if (ini == x) ini++; if (fin == x) fin++; if (fin == n) { break; } if (s[ini] != s[fin]) return false; ini++; fin++; } return true; } int main() { ios_base::sync_with_stdio(); cin.tie(); cin >> n >> s; len = n/2; for(int i=0; i<n; i++) { if (posible(i)) { r2 = r1; if (i <= len) r1 = s.substr(len+1, len); else r1 = s.substr(0, len); if (r2.size() == len && r1 != r2) { unico = false; break; } } } if (r1.size() != len || n&1 == 0) cout << "NOT POSSIBLE\n"; else if (!unico) cout << "NOT UNIQUE\n"; else cout << r1 << '\n'; return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:42:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |             if (r2.size() == len && r1 != r2) {
      |                 ~~~~~~~~~~^~~~~~
friends.cpp:48:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     if (r1.size() != len || n&1 == 0)
      |         ~~~~~~~~~~^~~~~~
friends.cpp:48:33: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   48 |     if (r1.size() != len || n&1 == 0)
      |                               ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...