QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#310822 | #4996. Icy Itinerary | OFforest_1273 | Compile Error | / | / | C++14 | 3.0kb | 2024-01-21 18:34:26 | 2024-01-21 18:34:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read(){int s=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();return s*f;}
const int N=3e5+10;
int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0;
vector<int> G[N];
int main(){
n=read(),m=read();
for(int i=1;i<=m;++i){
int u=read(),v=read();
G[u].push_back(v),G[v].push_back(u);
}
for(int i=1;i<=n;++i)sort(G[i].begin(),G[i].end());/*方便二分*/
for(int i=n;i;--i/*先将两个p数组反着来 方便添加点*/){
if(!c1){p1[++c1]=i;continue;}/*第一个必须是1*/
if(!c0){p0[++c0]=i;continue;}
int u0=p0[c0],u1=p1[c1];
int pos=lower_bound(G[u1].begin(),G[u1].end(),i)-G[u1].begin();
if(pos<G[u1].size()&&G[u1][pos]==i){p1[++c1]=i;continue;}
pos=lower_bound(G[u0].begin(),G[u0].end(),i)-G[u0].begin();
if(pos>=G[u0].size()||(pos<G[u0].size()&&G[u0][pos]!=i)){p0[++c0]=i;continue;}
pos=lower_bound(G[u1].begin(),G[u1].end(),u0)-G[u1].begin();
cout<<i<<" "<<pos<<" "<<G[u0].size()<<" "<<c1<<" "<<c0<<"\n";
if(pos<G[u1].size()&&G[u1][pos]==u0)--c0,p1[++c1]=u0,p1[++c1]=i;/*用u0将u1和i连接起来*/
else --c1,p0[++c0]=u1,p0[++c0]=i;/*将u0和i隔开*/
}
reverse(p1+1,p1+1+c1),reverse(p0+1,p0+1+c0);
if(p0[1]==1)swap(p0,p1),swap(c0,c1);
for(int i=1;i<=c1;++i)printf("%d ",p1[i]);
for(int i=1;i<=c0;++i)printf("%d ",p0[i]);
return 0;
}#include<bits/stdc++.h>
using namespace std;
inline int read(){int s=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();return s*f;}
const int N=3e5+10;
int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0;
vector<int> G[N];
int main(){
n=read(),m=read();
for(int i=1;i<=m;++i){
int u=read(),v=read();
G[u].push_back(v),G[v].push_back(u);
}
for(int i=1;i<=n;++i)sort(G[i].begin(),G[i].end());/*方便二分*/
for(int i=n;i;--i/*先将两个p数组反着来 方便添加点*/){
if(!c1){p1[++c1]=i;continue;}/*第一个必须是1*/
if(!c0){p0[++c0]=i;continue;}
int u0=p0[c0],u1=p1[c1];
int pos=lower_bound(G[u1].begin(),G[u1].end(),i)-G[u1].begin();
if(pos<G[u1].size()&&G[u1][pos]==i){p1[++c1]=i;continue;}
pos=lower_bound(G[u0].begin(),G[u0].end(),i)-G[u0].begin();
if(pos>=G[u0].size()||(pos<G[u0].size()&&G[u0][pos]!=i)){p0[++c0]=i;continue;}
pos=lower_bound(G[u1].begin(),G[u1].end(),u0)-G[u1].begin();
if(pos<G[u1].size()&&G[u1][pos]==u0)--c0,p1[++c1]=u0,p1[++c1]=i;/*用u0将u1和i连接起来*/
else --c1,p0[++c0]=u1,p0[++c0]=i;/*将u0和i隔开*/
}
reverse(p1+1,p1+1+c1),reverse(p0+1,p0+1+c0);
for(int i=1;i<=c1;++i)printf("%d ",p1[i]);
for(int i=1;i<=c0;++i)printf("%d ",p0[i]);
return 0;
}
Details
answer.code:32:2: error: stray ‘#’ in program 32 | }#include<bits/stdc++.h> | ^ answer.code:32:3: error: ‘include’ does not name a type 32 | }#include<bits/stdc++.h> | ^~~~~~~ answer.code:34:12: error: redefinition of ‘int read()’ 34 | inline int read(){int s=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();return s*f;} | ^~~~ answer.code:3:12: note: ‘int read()’ previously defined here 3 | inline int read(){int s=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();return s*f;} | ^~~~ answer.code:35:11: error: redefinition of ‘const int N’ 35 | const int N=3e5+10; | ^ answer.code:4:11: note: ‘const int N’ previously defined here 4 | const int N=3e5+10; | ^ answer.code:36:5: error: redefinition of ‘int n’ 36 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^ answer.code:5:5: note: ‘int n’ previously declared here 5 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^ answer.code:36:7: error: redefinition of ‘int m’ 36 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^ answer.code:5:7: note: ‘int m’ previously declared here 5 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^ answer.code:36:9: error: redefinition of ‘int p1 [300010]’ 36 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:5:9: note: ‘int p1 [300010]’ previously declared here 5 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:36:31: error: redefinition of ‘int p0 [300010]’ 36 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:5:31: note: ‘int p0 [300010]’ previously declared here 5 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:36:53: error: redefinition of ‘int c1’ 36 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:5:53: note: ‘int c1’ previously declared here 5 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:36:56: error: redefinition of ‘int c0’ 36 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:5:56: note: ‘int c0’ previously declared here 5 | int n,m,p1[N]/*有边的前一段*/,p0[N]/*没边的后一段*/,c1,c0; | ^~ answer.code:37:13: error: redefinition of ‘std::vector<int> G [300010]’ 37 | vector<int> G[N]; | ^ answer.code:6:13: note: ‘std::vector<int> G [300010]’ previously declared here 6 | vector<int> G[N]; | ^ answer.code:38:5: error: redefinition of ‘int main()’ 38 | int main(){ | ^~~~ answer.code:7:5: note: ‘int main()’ previously defined here 7 | int main(){ | ^~~~