이 제출은 이전 버전의 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) 메시지
friends.cpp: In function 'std::pair<bool, std::__cxx11::basic_string<char> > spr(const string&, const string&)':
friends.cpp:13:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < a.size(); ++i)
~~^~~~~~~~~~
friends.cpp:14:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (pt < b.size() and a[i] == b[pt])
~~~^~~~~~~~~~
friends.cpp:18:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (pt < b.size()) return {false, ""};
~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |