QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572017#9319. Bull Farmship2077#WA 120ms15824kbC++231.5kb2024-09-18 11:08:322024-09-18 11:08:32

Judging History

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

  • [2024-09-18 11:08:32]
  • 评测
  • 测评结果:WA
  • 用时:120ms
  • 内存:15824kb
  • [2024-09-18 11:08:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=2005;bool vis[M];
int n,m,q,p[M][M],siz[M],cnt[M],ans[M];
vector<int>vec[M];bitset<M>bit[M],edge[M];
vector<tuple<int,int,int>>qry[M];
void link(int x,int y){
	if (bit[x][y]) return;
	for (int i=1;i<=n;i++)
		if (bit[i][x]&&!bit[i][y])
			bit[i]|=bit[y];
}
void solve(){
	cin>>n>>m>>q;
	for (int i=1;i<=m;i++){
		string str;cin>>str;
		for (int j=1;j<=n;j++)
			p[i][j]=(str[j*2-2]-'0')*50+str[j*2-1]-'0';
	}
	for (int i=1;i<=q;i++){
		string str;cin>>str;
		int a=(str[0]-'0')*50+str[1]-'0';
		int b=(str[2]-'0')*50+str[3]-'0';
		int c=(str[4]-'0')*50+str[5]-'0';
		if (a==b) {ans[i]=1;continue;}
		if (i) qry[c].emplace_back(a,b,i); else ans[i]=0;
	}
	for (int i=1;i<=n;i++) edge[i].reset();
	for (int i=1;i<=n;i++) bit[i].reset(),bit[i][i]=1;
	for (int i=1;i<=m;i++){
		for (int j=1;j<=n;j++) vec[j].clear();
		int cnt=0,pos=0;
		for (int j=1;j<=n;j++) vec[p[i][j]].emplace_back(j);
		for (int j=1;j<=n;j++)
			if (vec[j].size()>1)
				cnt+=vec[j].size()-1,pos=j;
		if (cnt>1) goto jumping;
		if (!cnt){
			for (int j=1;j<=n;j++) link(j,p[i][j]);
			goto jumping;
		}
		{
			int p=0;
			for (int i=1;i<=n;i++)
				if (vec[i].empty()){
					p=i;break;
				}
			link(vec[pos][0],p);link(vec[pos][1],p);
		}
		jumping:
		for (auto [a,b,id]:qry[i])
			ans[id]=bit[a][b];
	}
	for (int i=1;i<=q;i++) putchar(ans[i]+'0');puts("");
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T;cin>>T;while (T--) solve();return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

2
5 2 4
0305040201
0404040404
030300
020500
050102
020501
6 2 4
030603010601
010203060504
030202
060402
050602
060401

output:

1011
0100

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 5696kb

input:

1
3 3 6
020202
030301
030201
020102
030203
010201
010303
020303
010202

output:

010101

result:

ok single line: '010101'

Test #3:

score: -100
Wrong Answer
time: 120ms
memory: 15824kb

input:

200
10 10 5000
01060:04020305080709
0103070:060204050908
09070503080401060:02
050308010204090:0607
03010502040607080:09
03080109020504060:07
06050:09040302080107
07080305010409060:02
030809010:0204060507
0:060908070201050304
060700
090:03
09080:
070405
010703
0:0100
080601
030600
070206
0:0:09
08040...

output:

011110001101101111111111111111111101111111110111011110110110111011010111111111111111111101111111111110111111110111111111111101111111111110111111111111111111110001100111111111111111111111111011101111111111111111111111111111111111111111011011110100111110111111110111111100111111101110111111111101111110...

result:

wrong answer 2nd lines differ - expected: '111111011101111011011111111111...1111110111111110111011110101111', found: '111111111101111111111111111111...1111111111111110111111111111111'