Submission #656197

#TimeUsernameProblemLanguageResultExecution timeMemory
656197600MihneaThree Friends (BOI14_friends)C++17
0 / 100
1068 ms8348 KiB
bool home = 0; bool verbose = 1; #include <bits/stdc++.h> using namespace std; int main() { if (!home) { verbose = 0; ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } if (home) { verbose = 1; freopen ("___input___.txt", "r", stdin); } int n; cin >> n; if (n % 2 == 0) { cout << "NOT POSSIBLE\n"; return 0; } assert((n - 1) % 2 == 0); int half = (n - 1) / 2; string s; cin >> s; assert((int) s.size() == n); int cnt = 0, pskip; for (int i = 0; i < n; i++) { string t = string(s.begin(), s.begin() + i) + string(s.begin() + i + 1, s.end()); assert((int) t.size() == n - 1); assert((int) t.size() == 2 * half); bool ok = 1; for (int j = 0; j < half; j++) { ok &= (t[j] == t[j + half]); } if (ok) { cnt++; pskip = i; } } if (cnt == 0) { cout << "NOT POSSIBLE\n"; return 0; } if (cnt >= 2) { cout << "NOT UNIQUE\n"; return 0; } string t = string(s.begin(), s.begin() + pskip) + string(s.begin() + pskip + 1, s.end()); t.resize((int) t.size() / 2); cout << t << "\n"; return 0; }

Compilation message (stderr)

friends.cpp: In function 'int main()':
friends.cpp:18:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen ("___input___.txt", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...