Submission #199481

#TimeUsernameProblemLanguageResultExecution timeMemory
199481SamAndLutrija (COCI19_lutrija)C++17
70 / 70
407 ms504 KiB
#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 (stderr)

lutrija.cpp: In function 'bool dfs(int)':
lutrija.cpp:32:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j < v.size(); ++j)
                     ~~^~~~~~~~~~
lutrija.cpp: In function 'int main()':
lutrija.cpp:63:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size(); ++i)
                     ~~^~~~~~~~~~
lutrija.cpp:65:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i + 1; j < v.size(); ++j)
                             ~~^~~~~~~~~~
lutrija.cpp:73:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size(); ++i)
                     ~~^~~~~~~~~~
lutrija.cpp:79:42: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<long long int>::size_type {aka long unsigned int}' [-Wformat=]
                 printf("%d\n", ans.size());
                                ~~~~~~~~~~^
lutrija.cpp:80:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int i = 0; i < ans.size(); ++i)
                                 ~~^~~~~~~~~~~~
lutrija.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...