제출 #958851

#제출 시각아이디문제언어결과실행 시간메모리
958851Pring세 명의 친구들 (BOI14_friends)C++17
100 / 100
8 ms9076 KiB
#include <bits/stdc++.h> using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define int long long #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) typedef pair<int, int> pii; int n; string s; string ans[2]; bitset<2> b; void SOLVE(int id, string l, string r) { int x = 0; for (auto &i : r) { if (x < l.size() && i == l[x]) x++; } if (x == l.size()) { b[id] = 1; ans[id] = l; return; } b[id] = 0; } void miku() { cin >> n >> s; if (n % 2 == 0) { cout << "NOT POSSIBLE" << '\n'; return; } SOLVE(0, s.substr(0, n / 2), s.substr(n / 2, n - n / 2)); SOLVE(1, s.substr(n / 2 + 1, n - n / 2 - 1), s.substr(0, n / 2 + 1)); if (!b[0] && !b[1]) { cout << "NOT POSSIBLE" << '\n'; return; } if (b[0] && b[1]) { cout << (ans[0] == ans[1] ? ans[0] : "NOT UNIQUE") << '\n'; return; } cout << (b[0] ? ans[0] : ans[1]) << '\n'; } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(cin.failbit); miku(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

friends.cpp: In function 'void SOLVE(long long int, std::string, std::string)':
friends.cpp:29:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if (x < l.size() && i == l[x]) x++;
      |             ~~^~~~~~~~~~
friends.cpp:31:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if (x == l.size()) {
      |         ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...