QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#85874#4513. Slide ParadeAFewSuns0 38ms51408kbC++142.7kb2023-03-08 20:03:542023-03-08 20:03:55

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-08 20:03:55]
  • 评测
  • 测评结果:0
  • 用时:38ms
  • 内存:51408kb
  • [2023-03-08 20:03:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
vector<ll> vec[220],ans;
ll t,n,m,to[220],head[220],cnt=0;
bl ck[220];
struct node{
	ll nxt,to;
}e[1000010];
void add(ll u,ll v){
	e[++cnt].nxt=head[u];
	e[cnt].to=v;
	head[u]=cnt;
}
bl match(ll u){
	fr(i,0,(ll)vec[u].size()-1){
		ll v=vec[u][i];
		if(!ck[v]){
			ck[v]=1;
			if(!to[v]||match(to[v])){
				to[v]=u;
				return 1;
			}
		}
	}
	return 0;
}
void dfs(ll u){
	ck[u]=1;
	for(ll i=head[u];i;i=head[u]){
		head[u]=e[i].nxt;
		dfs(e[i].to);
	}
	ans.push_back(u);
}
void clr(){
	fr(i,1,n) vec[i].clear();
	ans.clear();
	fr(i,1,n) head[i]=to[i]=0;
	cnt=0;
	fr(i,1,n) ck[i]=0;
}
int main(){
	t=read();
	fr(_,1,t){
		n=read();
		m=read();
		if(_==25) pf("%lld %lld\n",n,m);
		fr(i,1,m){
			ll u=read(),v=read();
			if(_==25) pf("%lld %lld\n",u,v);
			vec[u].push_back(v);
		}
		if(_!=25){
			clr();
			continue;
		}
		bl pd=0;
		fr(i,1,n){
			fr(j,1,n) ck[j]=0;
			if(!match(i)) pd=1;
		}
		fr(u,1,n){
			fr(i,0,(ll)vec[u].size()-1){
				ll v=vec[u][i];
				if(to[v]!=u){
					fr(j,1,n) if(to[j]==u) to[j]=0;
					ll w=to[v];
					to[v]=u;
					fr(j,1,n) ck[j]=0;
					ck[v]=1;
					if(!match(w)) pd=1;
				}
				fr(j,1,n) add(to[j],j);
			}
		}
		pf("Case #%lld: ",_);
		if(pd){
			pf("IMPOSSIBLE\n");
			clr();
			continue;
		}
		fr(i,1,n) ck[i]=0;
		dfs(1);
		writeln(ans.size());
		pfr(i,(ll)ans.size()-1,0) writesp(ans[i]);
		enter;
		clr();
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3592kb

input:

100
5 8
1 2
1 3
1 4
1 5
2 1
3 1
4 1
5 1
5 10
1 3
1 4
2 3
2 5
3 1
3 4
3 5
4 2
5 1
5 3
5 10
1 4
2 3
2 5
3 1
3 5
4 2
4 3
4 5
5 1
5 2
3 6
1 2
1 3
2 1
2 3
3 1
3 2
5 10
1 2
1 5
2 3
2 4
3 1
4 3
4 5
5 2
5 3
5 4
4 10
1 2
1 3
1 4
2 1
2 3
2 4
3 1
3 4
4 2
4 3
5 10
1 2
1 3
2 1
2 4
3 1
3 5
4 2
4 5
5 3
5 4
5 10
1 ...

output:

6 6
1 6
2 1
3 4
4 5
5 3
6 2
Case #25: 19
1 6 2 1 6 2 1 6 2 1 6 2 1 6 2 1 6 2 1 

result:

wrong output format Expected 'Case' but found '6' (test case 1)

Test #2:

score: 0
Wrong Answer
time: 38ms
memory: 51408kb

input:

100
199 4980
1 95
1 96
1 105
1 124
1 130
1 131
1 135
1 137
1 139
1 140
1 141
1 147
1 155
1 172
1 174
1 179
1 183
1 188
1 193
1 196
1 197
2 3
2 5
2 13
2 14
2 17
2 20
2 24
2 26
2 30
2 41
2 44
2 45
2 52
2 56
2 67
2 70
2 71
2 74
2 78
2 84
2 85
2 90
2 92
2 93
2 97
2 107
2 111
2 113
2 122
2 124
2 128
2 13...

output:

199 5000
1 99
1 104
2 3
2 11
2 20
2 21
2 32
2 33
2 34
2 35
2 37
2 47
2 49
2 50
2 55
2 59
2 66
2 71
2 72
2 74
2 77
2 82
2 85
2 87
2 88
2 89
2 91
2 92
2 93
2 97
2 99
2 102
2 108
2 109
2 112
2 113
2 114
2 115
2 120
2 121
2 131
2 136
2 143
2 145
2 152
2 156
2 158
2 159
2 162
2 163
2 177
2 188
2 198
3 5
...

result:

wrong output format Expected 'Case' but found '199' (test case 1)