| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 209324 | papa | Lutrija (COCI19_lutrija) | C++14 | 405 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
vector<int> adj[10];
vector<ll> svi;
vector<ll> filt;
int pre[10];
int vis[10];
//bfs resenje
bool bfs()
{
vis[0] = 1;
queue<int> q;
q.push(0);
while(!q.empty())
{
int x = q.front();
q.pop();
for(int s : adj[x])
{
if(!vis[s])
{
pre[s] = x;
vis[s] = 1;
q.push(s);
}
}
}
if(vis[filt.size()-1]) return true;
return false;
}
bool prime(ll x)
{
if(x==0) return false;
if(x==1) return false;
if(x==2) return true;
for(ll i = 2;i*i<=x;i++) if(x%i==0) return false;
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cerr.tie(0);
cin >> a >> b;
svi.push_back(a-2);
svi.push_back(a+2);
svi.push_back(2);
svi.push_back(b-2);
svi.push_back(b+2);
filt.push_back(a);
for(int i=0;i<svi.size();i++) if(prime(svi[i])) filt.push_back(svi[i]);
filt.push_back(b);
for(int i=0;i<filt.size()-1;i++)
{
for(int j=i+1;j<filt.size();j++)
{
if(prime(abs(filt[i]-filt[j])))
{
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
if(bfs())
{
int x = filt.size()-1;
stack<ll> st;
while(x > 0)
{
st.push(filt[x]);
x = pre[x];
}
cout << st.size() + 1 << "\n";
cout << a << " ";
while(!st.empty())
{
cout << st.top() << " ";
st.pop();
}
}
else cout << -1;
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... | ||||
