QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#310745 | #4996. Icy Itinerary | OFforest_1273 | WA | 4ms | 31328kb | C++14 | 2.0kb | 2024-01-21 17:22:11 | 2024-01-21 17:22:12 |
Judging History
answer
#include<bits/stdc++.h>
#define fep(i,l,r) for(int i=l;i<=r;++i)
#define feb(i,r,l) for(int i=r;i>=l;--i)
#define For(i,u) for(int i=head[u];i;i=e[i].nxt)
#define LL long long
#define ld long double
#define pr pair<int,int>
#define mpr make_pair
using namespace std;
const int N = 1e6+5,mod = 1e9+7;
inline int read()
{
int s=0,w=1; char ch=getchar();
while(!(ch>='0'&&ch<='9')) {if(ch=='-') w=-1; ch=getchar();}
while( ch>='0'&&ch<='9') {s=(s<<1)+(s<<3)+ch-'0'; ch=getchar();}
return s*w;
}
inline int Mod(int x) {return x>=mod?x-mod:x;}
inline void addmod(int &x,int y) {x=Mod(x+y);}
namespace starrylasky
{
int n,m,c0,c1,p0[N],p1[N]; vector<int > G[N];
inline void add(int u,int v) {G[u].emplace_back(v);}
inline void Main()
{
n=read(),m=read();
fep(i,1,m)
{
int u=read(),v=read();
add(u,v); add(v,u);
}
fep(i,1,n) sort(G[i].begin(),G[i].end());
fep(i,1,n)
{
if(!c1) {p1[++c1]=i; continue;}
if(!c0) {p0[++c0]=i; continue;}
int u1=p1[c1],u0=p0[c0];
int p=lower_bound(G[u1].begin(),G[u1].end(),i)-G[u1].begin();
if(p<G[u1].size()&&G[u1][p]==i) {p1[++c1]=i; continue;}
p=lower_bound(G[u0].begin(),G[u0].end(),i)-G[u0].begin();
// cerr<<i<<" "<<p<<" "<<G[u0].size()<<" "<<c1<<" "<<c0<<"\n";
if(p==G[u0].size()||(p<G[u0].size()&&G[u0][p]!=i)) {p0[++c0]=i; continue;}
p=lower_bound(G[u1].begin(),G[u1].end(),u0)-G[u1].begin();
if(p<G[u1].size()&&G[u1][p]==u0) --c0,p1[++c1]=u0,p1[++c1]=i;
else --c1,p0[++c0]=u1,p0[++c0]=i;
}
// reverse(p1+1,p1+c1+1);
// reverse(p0+1,p0+c0+1);
if(p0[1]==1) swap(p0,p1),swap(c0,c1);
fep(i,1,c1) printf("%d ",p1[i]);
fep(i,1,c0) printf("%d ",p0[i]);
}
}
signed main(){
int _T=1;
while(_T--) starrylasky::Main();
return 0;
}/*check*/
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 31328kb
input:
4 4 1 2 1 3 1 4 3 4
output:
1 3 4 2
result:
ok qwq
Test #2:
score: 0
Accepted
time: 3ms
memory: 31004kb
input:
5 0
output:
1 2 3 4 5
result:
ok qwq
Test #3:
score: -100
Wrong Answer
time: 3ms
memory: 30472kb
input:
10 10 7 8 7 5 5 2 6 1 10 7 4 6 5 8 3 2 10 5 1 10
output:
9 2 1 3 5 6 7 4 8 10
result:
wrong answer The first number wasn't 1