# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
968753 | youssef_3breheem | 세 명의 친구들 (BOI14_friends) | C++17 | 30 ms | 5448 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool isPossible(const string& u) {
if (u.size() % 2 != 0) // If the length of U is odd, it's impossible to create S
return false;
string t = u.substr(0, u.size() / 2); // Split U into two equal parts to form T
string s;
// Iterate through all possible positions to split T into two copies of S
for (int i = 1; i < t.size(); ++i) {
string s1 = t.substr(0, i);
string s2 = t.substr(i);
string reconstructedU = s2 + s1 + s2; // Reconstruct U using the two copies of S
if (reconstructedU == u) { // If the reconstructed U matches the given U
if (s.empty()) { // If s is empty, store the current value of S
s = s1;
} else if (s != s1) { // If s is not empty and doesn't match the current value of S, S is not unique
return false;
}
}
}
return !s.empty(); // If S is not empty, it's possible to create S and it's unique
}
int main() {
int n;
cin >> n;
string u;
cin >> u;
if (!isPossible(u)) {
cout << "NOT POSSIBLE" << endl;
} else {
cout << (isPossible(u) ? "NOT UNIQUE" : u) << endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |