Submission #1121395

#TimeUsernameProblemLanguageResultExecution timeMemory
1121395qrnLutrija (COCI19_lutrija)C++14
0 / 70
517 ms5156 KiB
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define pb push_back // #define endl "\n" #define ALL(x) x.begin(), x.end() #define intt long long const intt mxN = 2e5 + 5, L = 20, mxA = 5e5 + 35; bool isprime(intt n) { for(int i = 2; i <= sqrt(n); i++) { if(n % i == 0) return false; } return true; } vector<vector<intt>>graph; vector<intt> parent(mxN, 0), visited(mxN, 0), path, memopath, v(mxN); bool ok = false; void dfs(int u, int end) { visited[u] = true; path.pb(u); if (u == end) { ok = true; for(int i = 0; i < path.size(); i++) { if(i < path.size() - 1 && v[path[i]] == v[path[i+1]]) { continue; } if(v[path[i]] == v[end]) { cout << v[path[i]] << " "; return; } else { cout << v[path[i]] << " "; } } return; } else { for (int v : graph[u]) { if (!visited[v]) { dfs(v, end); } } } path.pop_back(); visited[u] = false; } void solve() { intt l,r, li =0, ri = 0; cin >> l >> r; v.resize(8); v = {-mxA, 2, l - 2, r - 2, l, r, l + 2, r + 2}; sort(ALL(v)); graph.resize(8); for(intt i = 1; i <= 7; i++) { if(v[i] == l) li = i; if(v[i] == r) ri = i; for(intt j = i + 1; j <= 7; j++) { if(isprime(v[i]) && isprime(v[j]) && isprime(abs(v[i]-v[j])) && v[i] && v[j]){ graph[i].pb(j); graph[j].pb(i); } } } dfs(li, ri); if(!ok) { cout << -1 << endl; } } int main() { SPEED; int tst = 1; // cin >> tst; while (tst--) { solve(); } return 0; }

Compilation message (stderr)

lutrija.cpp: In function 'void dfs(int, int)':
lutrija.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i = 0; i < path.size(); i++) {
      |                        ~~^~~~~~~~~~~~~
lutrija.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             if(i < path.size() - 1 && v[path[i]] == v[path[i+1]]) {
      |                ~~^~~~~~~~~~~~~~~~~
#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...