Submission #728781

#TimeUsernameProblemLanguageResultExecution timeMemory
728781rominanafuThree Friends (BOI14_friends)C++11
0 / 100
50 ms7140 KiB
#include <bits/stdc++.h> using namespace std; int n, len; string s; string r1, r2; bool unico = true; bool caso1() { int ini = 0, fin = len+1; bool x = false; int cont=0; while (cont < len) { if (s[ini] != s[fin]) { ini++; x = true; } if (x && s[ini] != s[fin]) return false; ini++; fin++; cont++; } return true; } bool caso2() { int ini = 0, fin = len; bool x = false; int cont=0; while (cont < len) { if (s[ini] != s[fin]) { fin++; x = true; } if (x && 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; string r1 = "", r2 = ""; if (caso1()) r1 = s.substr(len+1, len); if (caso2()) r2 = s.substr(0, len); if ((r1.length() != len && r2.length() != len) || (n&1) == 0) cout << "NOT POSSIBLE"; else if (r1.length() != len) cout << r2; else if (r2.length() != len) cout << r1; else if (r1 != r2) cout << "NOT UNIQUE"; else cout << r1; return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:56:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |     if ((r1.length() != len && r2.length() != len) || (n&1) == 0)
      |          ~~~~~~~~~~~~^~~~~~
friends.cpp:56:44: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |     if ((r1.length() != len && r2.length() != len) || (n&1) == 0)
      |                                ~~~~~~~~~~~~^~~~~~
friends.cpp:58:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |     else if (r1.length() != len)
      |              ~~~~~~~~~~~~^~~~~~
friends.cpp:60:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     else if (r2.length() != len)
      |              ~~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...