이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
// #include <bits/extc++.h>
using namespace std;
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a, val) memset(a, val, sizeof (a))
#define PB push_back
#define endl '\n'
typedef long long ll;
inline int myrand(int l, int r) {
int ret = rand(); ret <<= 15; ret ^= rand();
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
return os<<"(" <<p.first<<", "<<p.second<<")"; }
typedef pair<int, int> ii;
template<typename T> using min_pq =
std::priority_queue<T, vector<T>, greater<T> >;
//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};
bool can(string s, string p) {
for(int i = 0; i < s.size(); i++) {
if(s[i] != p[i]) {
p.erase(p.begin() + i);
return s == p;
}
} return true;
}
int32_t main () {
// freopen("in", "r", stdin);
int n; cin >> n;
if(n % 2 == 0) {
cout << "NOT POSSIBLE" << endl;
return 0;
}
string s; cin >> s;
string L = s.substr(0, (n >> 1));
string LL = s.substr(0, (n >> 1) + 1);
string R = s.substr((n >> 1) + 1, (n >> 1));
string RR = s.substr((n >> 1), (n >> 1) + 1);
assert(L + RR == s and LL + R == s);
set<string> st;
if(can(L, RR)) st.insert(L);
if(can(R, LL)) st.insert(R);
if(st.size() > 1) cout << "NOT UNIQUE" << endl;
else if(can(L, RR)) cout << L << endl;
else if(can(R, LL)) cout << R << endl;
else cout << "NOT POSSIBLE" << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
friends.cpp: In function 'int myrand(int, int)':
friends.cpp:18:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
^~
friends.cpp:18:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
^~~
friends.cpp: In function 'bool can(std::__cxx11::string, std::__cxx11::string)':
friends.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < s.size(); i++) {
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |