# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
439425 | 2021-06-29T21:14:17 Z | Yomapeed | Lutrija (COCI19_lutrija) | C++17 | 687 ms | 324 KB |
#include<bits/stdc++.h> #define pi 3.141592653589793238 #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool prime(ll n){ if(n <= 1){ return false; } for(ll i = 2; i * i <= n; i++){ if(n % i == 0){ return false; } } return true; } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); fast; ll T = 1, i, j; //cin >> T; while (T--) { ll l, r; cin >> l >> r; if(prime(r - l)){ cout << "2\n"; cout << l << " " << r << "\n"; return 0; } vector<ll> x = {l, r}; set<ll> s; for(auto u : x){ for(i = -2; i <= 2; i += 2){ if(prime(u + i)){ s.insert(u + i); } } } s.insert(2); map<ll,ll> visited; vector<ll> ans; function<void(ll)> dfs = [&](ll a){ visited[a] = 1; ans.pb(a); if(a == r){ cout << ans.size() << endl; for(auto u : ans){ cout << u << " "; } cout << endl; return; } for(auto u : s){ if(prime(abs(u - a)) && !visited[u]){ dfs(u); } } ans.pop_back(); }; dfs(l); if(ans.empty()){ cout << "-1\n"; } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 312 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 636 ms | 296 KB | Output is correct |
2 | Correct | 234 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 621 ms | 288 KB | Output is correct |
2 | Correct | 202 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 687 ms | 296 KB | Output is correct |
2 | Correct | 251 ms | 288 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 501 ms | 324 KB | Output is correct |
2 | Correct | 173 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |