| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 125437 | wasyl | Three Friends (BOI14_friends) | C++11 | 19 ms | 9112 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
constexpr int nax = 2e6 + 1;
int n;
string s;
pair< bool, string > spr(const string& a, const string& b)
{
//cerr << a << ' ' << b << ' ';
int pt = 0;
for (int i = 0; i < a.size(); ++i)
if (pt < b.size() and a[i] == b[pt])
++pt;
//cerr << pt << '\n';
if (pt < b.size()) return {false, ""};
else return {true, b};
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> s;
if (n % 2 == 0)
return cout << "NOT POSSIBLE" << '\n', 0;
int d = (n - 1) / 2;
pair< bool, string > p, q;
p = spr(s.substr(0, d + 1), s.substr(d + 1, d));
q = spr(s.substr(d, d + 1), s.substr(0, d));
if (p.first and q.first and (p.second != q.second))
return cout << "NOT UNIQUE" << '\n', 0;
if (not p.first) swap(p, q);
if (not p.first)
cout << "NOT POSSIBLE" << '\n';
else
cout << p.second << '\n';
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
