Submission #728776

#TimeUsernameProblemLanguageResultExecution timeMemory
728776rominanafuThree Friends (BOI14_friends)C++11
35 / 100
1074 ms6116 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++; int cont=0; while (cont < len) { if (ini == x) ini++; if (fin == x) fin++; if (fin == n) { break; } if (s[ini] != s[fin]) return false; ini++; fin++; cont++; } 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.length() != 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:44:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |             if (r2.size() == len && r1 != r2) {
      |                 ~~~~~~~~~~^~~~~~
friends.cpp:50:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |     if (r1.length() != len || (n&1) == 0)
      |         ~~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...