QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695939#5520. Distance ParitiesHRcohcWA 0ms3904kbC++141.6kb2024-10-31 21:07:322024-10-31 21:07:33

Judging History

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

  • [2024-10-31 21:07:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3904kb
  • [2024-10-31 21:07:32]
  • 提交

answer

#include <bits/stdc++.h>
#define N 505
#define pb push_back
using namespace std;
inline int read(){
	char ch = getchar(); int x = 0, f = 1;
	while(!isdigit(ch)){if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)){x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int T, n, m;
char s[N];
int g[N][N], fa[N], d[N];
vector<int> e[N];
queue<int> q;
bitset<N> vis;

int find(int x){return (x == fa[x])? x : fa[x] = find(fa[x]);}
void merge(int x, int y){int f1 = find(x), f2 = find(y); fa[f1] = f2;}

bool check(int x){
	queue<int>().swap(q), vis.reset();
	d[x] = 0; q.push(x); vis[x] = 1;
	while(!q.empty()){
		int u = q.front(); q.pop();
		for(int v : e[u]){
			if(vis[v]) continue;
			d[v] = d[u] ^ 1; q.push(v); vis[v] = 1;
			if(d[v] ^ g[x][v]) return 0;
		}
	}
	return 1;
}

void solve(){
	n = read(); m = 0;
	for(int i = 1; i <= n; i++){
		scanf(" %s", s + 1);
		fa[i] = i, vector<int>().swap(e[i]);
		for(int j = 1; j <= n; j++) g[i][j] = s[j] - '0';
	}
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			if(!g[i][j]) continue;
			if(!g[j][i]) goto FAIL;
			merge(i, j);
			e[i].pb(j), e[j].pb(i);
			++m;
		}
	}
	for(int i = 2; i <= n; i++) if(find(i) ^ find(1)) goto FAIL;
	for(int i = 1; i <= n; i++) if(!check(i)) goto FAIL;
	puts("Pure Memory");
	printf("%d\n", m);
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++) if(g[i][j]) printf("%d %d\n", i, j);
	}
	return;
	FAIL: puts("Track Lost"); return;
}

int main(){
//	freopen("bridge.in", "r", stdin);
//	freopen("bridge.out", "w", stdout);
	T = read();
	while(T--) solve();
	return 0;
} 

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3904kb

input:

3
3
011
101
110
4
0100
1000
0001
0010
5
01010
10101
01010
10101
01010

output:

Pure Memory
3
1 2
1 3
2 3
Track Lost
Pure Memory
6
1 2
1 4
2 3
2 5
3 4
4 5

result:

wrong answer Token parameter [name=yes/no] equals to "Pure", doesn't correspond to pattern "[yY][eE][sS]|[nN][oO]" (test case 1)