# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
735662 | josanneo22 | Three Friends (BOI14_friends) | C++17 | 1079 ms | 73232 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define int long long
#define mp make_pair
#define fi first
#define se second
set<int> st;
unordered_map<string,int> ans;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
string s; cin >> s;
if (n % 2 == 0) {
cout << "NOT POSSIBLE\n";
return 0;
}
int pt = 0, jump = n / 2;
string p = "";
for (int i = 1; i < n; i++) {
p += s[i];
}
for (int i = 0; i < p.size(); i++) {
if (i + jump <= p.size() - 1 && p[i] != p[i + jump]) {
st.insert(i);
st.insert(i + jump);
}
}
while (pt <= n - 1) {
if (st.size() == 0) {
ans[p]=1;
}
p[pt] = s[pt];
auto pos = st.find(pt);
if (pos != st.end()) st.erase(pos);
if (pt + jump <= n - 2) {
pos = st.find(pt + jump);
if (pos != st.end()) st.erase(pos);
}
if (pt - jump <= n - 2){
pos = st.find(pt - jump);
if (pos != st.end()) st.erase(pos);
}
if (pt + jump <= n - 2 && p[pt] != p[pt + jump]) {
st.insert(pt);
st.insert(pt + jump);
}
if(pt -jump>=0 && p[pt] != p[pt - jump]){
st.insert(pt);
st.insert(pt - jump);
}
pt++;
}
if (ans.size()==1){
for(auto it=ans.begin();it!=ans.end();it++){
string save=it->first;
cout<<save.substr(0,n/2);
return 0;
}
}
else if(ans.size()==0) cout << "NOT POSSIBLE\n";
else cout << "NOT UNIQUE";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |