QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572024#9319. Bull Farmship2077#WA 1ms5716kbC++231.6kb2024-09-18 11:11:182024-09-18 11:11:20

Judging History

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

  • [2024-09-18 11:11:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5716kb
  • [2024-09-18 11:11:18]
  • 提交

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++) qry[i].clear();
	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: 0
Wrong Answer
time: 1ms
memory: 5716kb

input:

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

output:

1000
1000

result:

wrong answer 1st lines differ - expected: '1011', found: '1000'