QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#112911 | #6391. Airplane | LFCode | 0 | 14ms | 13704kb | C++14 | 1.6kb | 2023-06-15 11:09:16 | 2023-06-15 11:09:19 |
Judging History
answer
#include<cstdio>
#include<queue>
using namespace std;
const int N=200086,M=400086,INF=2e9;
int n,m,tot=1,a[N],d[2][N],eu[M],ev[M],h[N];
struct edge{int v,nxt;}e[M<<1];
struct node{
int no,dis;
node(int n,int d){no=n;dis=d;}
bool operator <(const node b)const{return b.dis>dis;}
};
priority_queue<node>q;
int Max(int a,int b){return a>b?a:b;}
int Min(int a,int b){return a<b?a:b;}
int read(){
char ch=getchar();int nn=0,ssss=1;
while(ch<'0'||ch>'9'){if(ch=='-')ssss*=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){nn=nn*10+(ch-'0');ch=getchar();}
return nn*ssss;
}
bool add(int u,int v){e[++tot].v=v;e[tot].nxt=h[u];h[u]=tot;return true;}
bool dij(int s,int flr){
for(int i=1;i<=n;i++)d[flr][i]=INF;
while(!q.empty())q.pop();q.push(node(s,d[flr][s]=0));
while(!q.empty()){
node np=q.top();q.pop();if(np.dis!=d[flr][np.no])continue;
for(int i=h[np.no];i;i=e[i].nxt){
int nd=Max(d[flr][np.no]+1,a[e[i].v]);
if(nd<d[flr][e[i].v])q.push(node(e[i].v,d[flr][e[i].v]=nd));
}
}
return true;
}
int main(){
n=read();m=read();for(int i=1;i<=n;i++)a[i]=read();
for(int i=1;i<=m;i++){
eu[i]=read();ev[i]=read();
if(eu[i]>ev[i]){eu[i]+=ev[i];ev[i]=eu[i]-ev[i];eu[i]-=ev[i];}
add(eu[i],ev[i]);add(ev[i],eu[i]);
}
dij(1,0);dij(n,1);int ans=INF;
for(int i=2;i<n;i++)ans=Min(ans,d[0][i]+d[1][i]);
for(int i=1;i<=m;i++){
if(eu[i]==1&&ev[i]==n){printf("0");return 0;}
if(eu[i]==1||ev[i]==n)continue;
if(a[eu[i]]>=a[ev[i]])ans=Min(ans,d[0][eu[i]]+1+d[1][ev[i]]);
if(a[ev[i]]>=a[eu[i]])ans=Min(ans,d[0][ev[i]]+1+d[1][eu[i]]);
}
printf("%d",ans);
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 14ms
memory: 13704kb
input:
200000 199999 0 199 58 60 83 5 10 182 87 65 104 153 197 137 80 143 34 181 62 48 10 57 86 58 117 10 171 188 95 52 95 140 126 0 196 85 87 14 10 139 177 92 31 18 102 146 68 9 91 124 156 38 41 121 183 10 32 174 171 29 49 26 118 1 69 185 57 168 54 159 195 95 9 32 195 70 85 174 158 82 33 197 66 189 198 11...
output:
200298
result:
wrong answer 1st lines differ - expected: '200378', found: '200298'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 6924kb
input:
6 10 0 0 6 1 8 0 5 6 2 3 5 4 6 4 3 5 6 2 3 6 3 4 3 1 6 1
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%