# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
223892 | penguinhacker | Lutrija (COCI19_lutrija) | C++14 | 700 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//TASK: Lutrija
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool check(ll n) {
if (n<2)
return false;
for (ll i=2; i*i<=n; ++i) {
if (n%i==0)
return false;
}
return true;
}
ll A, B, diff;
vector<ll> nodes;
map<pair<ll, ll>, bool> adj;
vector<ll> path;
void dfs(ll u) {
path.push_back(u);
if (u==B) {
cout << path.size() << '\n';
for (int i=0; i<path.size(); ++i) {
cout << path[i] << (i<path.size()-1?' ':'\n');
}
exit(0);
}
for (int i=0; i<nodes.size(); ++i) {
if (adj[make_pair(u, nodes[i])]&&find(path.begin(), path.end(), nodes[i])==path.end()) {
dfs(nodes[i]);
}
}
path.pop_back();
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> A >> B;
set<ll> temp;
temp.insert(2);
for (int i=-1; i<=1; ++i) {
if (check(A+2*i))
temp.insert(A+2*i);
if (check(B+2*i))
temp.insert(B+2*i);
}
for (const ll &i : temp)
nodes.push_back(i);
int n = nodes.size();
for (int i=0; i<n; ++i) {
for (int j=0; j<n; ++j) {
adj[make_pair(nodes[i], nodes[j])] = 0;
if (check(abs(nodes[i]-nodes[j]))) {
adj[make_pair(nodes[i], nodes[j])] = 1;
}
}
}
dfs(A);
cout << -1 << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |