QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#571999#9319. Bull Farmship2077#WA 105ms16052kbC++231.6kb2024-09-18 10:58:322024-09-18 10:58:33

Judging History

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

  • [2024-09-18 10:58:33]
  • 评测
  • 测评结果:WA
  • 用时:105ms
  • 内存:16052kb
  • [2024-09-18 10:58: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];
struct info{ int x,d;
	bool operator <(const info &a) const
		{return a.d<d;}
};
void link(int x,int y){
	// cerr<<x<<"->"<<y<<"!"<<endl;
	for (int i=1;i<=n;i++)
		if (bit[i][x])
			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;}ans[i]=0;
		if (i) qry[c].emplace_back(a,b,i);
	}
	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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5692kb

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: 0ms
memory: 3684kb

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: 105ms
memory: 16052kb

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: '111111111101111011111111111111...1111111111111110111111111111111'