# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199481 | 2020-02-01T14:32:48 Z | SamAnd | Lutrija (COCI19_lutrija) | C++17 | 407 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; long long a, b; bool stgg(long long x) { if (x <= 1) return false; for (long long i = 2; i * i <= x; ++i) { if (x % i == 0) return false; } return true; } vector<long long> v; bool c[7][7]; vector<long long> ans; bool cc[7]; bool dfs(int i) { if (cc[i]) return false; cc[i] = true; ans.push_back(v[i]); if (v[i] == b && ans.size() > 1) return true; for (int j = 0; j < v.size(); ++j) { if (c[i][j]) { if (dfs(j)) return true; } } ans.pop_back(); return false; } int main() { scanf("%lld%lld", &a, &b); if (a == 2 && b == 2) { printf("3\n2 5 2\n"); return 0; } if (stgg(a - 2)) v.push_back(a - 2); v.push_back(a); if (stgg(a + 2)) v.push_back(a + 2); if (stgg(b - 2)) v.push_back(b - 2); v.push_back(b); if (stgg(b + 2)) v.push_back(b + 2); v.push_back(2); for (int i = 0; i < v.size(); ++i) { for (int j = i + 1; j < v.size(); ++j) { if (stgg(abs(v[i] - v[j]))) { c[i][j] = c[j][i] = true; } } } for (int i = 0; i < v.size(); ++i) { if (v[i] == a) { if (dfs(i)) { printf("%d\n", ans.size()); for (int i = 0; i < ans.size(); ++i) printf("%lld ", ans[i]); printf("\n"); return 0; } printf("-1\n"); return 0; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 128 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 6 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 7 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 337 ms | 364 KB | Output is correct |
2 | Correct | 200 ms | 256 KB | Output is correct |
3 | Correct | 407 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 332 ms | 504 KB | Output is correct |
2 | Correct | 198 ms | 380 KB | Output is correct |
3 | Correct | 293 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 365 ms | 504 KB | Output is correct |
2 | Correct | 192 ms | 256 KB | Output is correct |
3 | Correct | 270 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 280 ms | 376 KB | Output is correct |
2 | Correct | 149 ms | 256 KB | Output is correct |
3 | Correct | 98 ms | 376 KB | Output is correct |