제출 #380424

#제출 시각아이디문제언어결과실행 시간메모리
380424BeanZ세 명의 친구들 (BOI14_friends)C++14
100 / 100
34 ms7148 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 2e5 + 5; long long mod = 1e9 + 7; const int lim = 2e5; const int lg = 19; const int base = 311; const long double eps = 1e-6; ll n; string s; string chk(ll l1, ll r1, ll l2, ll r2){ bool flag = false; string t; for (int i = l1; i <= r1; i++){ if (s[i] == s[l2]){ l2++; } else if (s[i] == s[l2 + 1] && !flag){ l2 += 2; flag = true; } else { return "-1"; } } for (int i = l1; i <= r1; i++) t.push_back(s[i]); return t; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("tests.inp", "r")){ freopen("tests.inp", "r", stdin); freopen("tests.out", "w", stdout); } cin >> n; cin >> s; s = " " + s; if ((n % 2) == 0) return cout << "NOT POSSIBLE", 0; string one = chk(1, n / 2, n / 2 + 1, n); string two = chk(n / 2 + 2, n, 1, n / 2 + 1); if (one == "-1" && two == "-1") return cout << "NOT POSSIBLE", 0; if (one != "-1" && two != "-1" && one != two) return cout << "NOT UNIQUE", 0; if (one == "-1") return cout << two, 0; else return cout << one, 0; } /* Ans: Out: */

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

friends.cpp: In function 'int main()':
friends.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   34 |         freopen("tests.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
friends.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   35 |         freopen("tests.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...