QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#19848 | #2289. Jail or Joyride | wxp# | Compile Error | / | / | C++14 | 2.8kb | 2022-02-12 14:28:10 | 2022-05-18 04:07:40 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2022-05-18 04:07:40]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2022-02-12 14:28:10]
- 提交
answer
2 3#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define per(i,x,y) for(int i=x;i>=y;--i)
#define mar(o) for(int E=fst[o];E;E=e[E].nxt)
#define v e[E].to
#define lon long long
#define die(x,y) memset(x,y,sizeof x)
using namespace std;
const int n7=520,m7=501234;
const lon inf=1000000000000000;
struct dino{int to,nxt,w;}e[m7];
int n,m,me,mez,yo,ecnt,fst[n7],vis[n7],laf[n7],u[n7],ddis[n7];
lon dis[n7][n7],maxx,maxn,minx,minn,ans;
int rd(){
int shu=0;bool fu=0;char ch=getchar();
while( !isdigit(ch) ){if(ch=='-')fu=1;ch=getchar();}
while( isdigit(ch) )shu=(shu<<1)+(shu<<3)+ch-'0',ch=getchar();
return fu?-shu:shu;
}
void edge(int p,int q,int w){
ecnt++;
e[ecnt]=(dino){q,fst[p],w};
fst[p]=ecnt;
}
void dfs0(int o){
vis[o]=1;
int flag=0;
mar(o){
flag++;
if(vis[v])continue;
dfs0(v);
}
if(flag<2)laf[o]=1;
}
int dfs1(int o,int w){
vis[o]=1;
int cnt=0;
mar(o){
if(vis[v])continue;
if(v==yo){
cnt++;
if(w<minx)minx=w,mez=o;
}
else cnt+=dfs1(v,w+e[E].w);
if(cnt>1)return cnt;
}
return cnt;
}
void dijk(){
memset(ddis,0x3f,sizeof ddis),ddis[yo]=0;
priority_queue < pair<lon,int> > que;
que.push( make_pair(0,yo) );
while( !que.empty() ){
int o=que.top().second;que.pop();
if(u[o])continue;
u[o]=1;
mar(o){
if(v==me)continue;
if(ddis[v]>ddis[o]+e[E].w){
ddis[v]=ddis[o]+e[E].w;
if(!u[v])que.push( make_pair(-ddis[v],v) );
}
}
}
}
bool work0(){
mez=me;
if( dfs1(me,0)>1 ){ans+=minx;return 1;}
ans+=minx,me=mez;
dijk();
maxx=0;
rep(i,1,n)if(ddis[i]^ddis[0]&&ddis[i]>maxx)maxx=ddis[i],maxn=i;
yo=maxn;
die(vis,0),minx=inf;
if( dfs1(me,0)==1 ){
printf("%lld\n",ans+minx);
return 0;
}
return 1;
}
bool dfs3(int o,int fa){
vis[o]=1;
mar(o){
if(v==fa)continue;
if(vis[v])return 1;
if( dfs3(v,o) )return 1;
}
return 0;
}
void dfs4(int o,int fa,int w){
if(w>maxx)maxx=w,maxn=o;
mar(o){
if(v==fa)continue;
dfs4(v,o,w+e[E].w);
}
}
int main(){
n=rd(),m=rd(),me=rd(),yo=rd();
memset(dis,0x3f,sizeof dis);
rep(i,1,n)dis[i][i]=0;
rep(i,1,m){
int p=rd(),q=rd();lon w=rd();
edge(p,q,w),edge(q,p,w);
dis[p][q]=dis[q][p]=min(dis[p][q],w);
}
die(vis,0),dfs0(1);
die(vis,0),dfs0(2);
die(vis,0);
if( !work0() )return 0;
die(fst,0),ecnt=0;
rep(k,1,n)rep(i,1,n)rep(j,1,n){
dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
}
ans+=dis[me][yo];
rep(i,1,n){
if(laf[i])continue;
int mxa=i;
rep(j,1,n){
if(dis[i][j]>dis[i][mxa])mxa=j;
if(dis[i][j]==dis[i][mxa]&&!laf[j])mxa=j;
}
edge(i,mxa,dis[i][mxa]),edge(mxa,i,dis[i][mxa]);
}
die(vis,0);
if( dfs3(yo,0) )return puts("impossible"),0;
maxx=0,dfs4(yo,0,0);
printf("%lld",ans+maxx);
return 0;
}
Details
answer.code:1:4: error: stray ‘#’ in program 1 | 2 3#include<bits/stdc++.h> | ^ answer.code:1:1: error: expected unqualified-id before numeric constant 1 | 2 3#include<bits/stdc++.h> | ^ answer.code: In function ‘int rd()’: answer.code:16:37: error: ‘getchar’ was not declared in this scope 16 | int shu=0;bool fu=0;char ch=getchar(); | ^~~~~~~ answer.code:1:1: note: ‘getchar’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’? +++ |+#include <cstdio> 1 | 2 3#include<bits/stdc++.h> answer.code:17:17: error: ‘isdigit’ was not declared in this scope 17 | while( !isdigit(ch) ){if(ch=='-')fu=1;ch=getchar();} | ^~~~~~~ answer.code:18:16: error: ‘isdigit’ was not declared in this scope 18 | while( isdigit(ch) )shu=(shu<<1)+(shu<<3)+ch-'0',ch=getchar(); | ^~~~~~~ answer.code: In function ‘void dijk()’: answer.code:55:9: error: ‘memset’ was not declared in this scope 55 | memset(ddis,0x3f,sizeof ddis),ddis[yo]=0; | ^~~~~~ answer.code:1:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? +++ |+#include <cstring> 1 | 2 3#include<bits/stdc++.h> answer.code:56:9: error: ‘priority_queue’ was not declared in this scope 56 | priority_queue < pair<lon,int> > que; | ^~~~~~~~~~~~~~ answer.code:56:26: error: ‘pair’ was not declared in this scope 56 | priority_queue < pair<lon,int> > que; | ^~~~ answer.code:6:13: error: expected primary-expression before ‘long’ 6 | #define lon long long | ^~~~ answer.code:56:31: note: in expansion of macro ‘lon’ 56 | priority_queue < pair<lon,int> > que; | ^~~ answer.code:57:9: error: ‘que’ was not declared in this scope 57 | que.push( make_pair(0,yo) ); | ^~~ answer.code:57:19: error: ‘make_pair’ was not declared in this scope 57 | que.push( make_pair(0,yo) ); | ^~~~~~~~~ answer.code: In function ‘bool work0()’: answer.code:7:18: error: ‘memset’ was not declared in this scope 7 | #define die(x,y) memset(x,y,sizeof x) | ^~~~~~ answer.code:80:9: note: in expansion of macro ‘die’ 80 | die(vis,0),minx=inf; | ^~~ answer.code:7:18: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 7 | #define die(x,y) memset(x,y,sizeof x) | ^~~~~~ answer.code:80:9: note: in expansion of macro ‘die’ 80 | die(vis,0),minx=inf; | ^~~ answer.code:82:17: error: ‘printf’ was not declared in this scope 82 | printf("%lld\n",ans+minx); | ^~~~~~ answer.code:82:17: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’? answer.code: In function ‘int main()’: answer.code:108:9: error: ‘memset’ was not declared in this scope 108 | memset(dis,0x3f,sizeof dis); | ^~~~~~ answer.code:108:9: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? answer.code:113:37: error: ‘min’ was not declared in this scope; did you mean ‘minx’? 113 | dis[p][q]=dis[q][p]=min(dis[p][q],w); | ^~~ | minx answer.code:121:27: error: ‘min’ was not declared in this scope; did you mean ‘minx’? 121 | dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]); | ^~~ | minx answer.code:134:32: error: ‘puts’ was not declared in this scope 134 | if( dfs3(yo,0) )return puts("impossible"),0; | ^~~~ answer.code:136:9: error: ‘printf’ was not declared in this scope 136 | printf("%lld",ans+maxx); | ^~~~~~ answer.code:136:9: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?