论#2测试点
查看原帖
论#2测试点
728090
RaynorLzj楼主2024/7/21 23:27

大家可否告诉本蒟蒻为什么输入数据存在重复的三角形
贴代码一份

// Problem: P1488 肥猫的游戏
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1488
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// Author: Leizijin
// 
// Powered by CP Editor (https://cpeditor.org)
// 若黑三角形只有一条边相连,那么先手胜
// 如果有两条边相连,n<-n-2,奇偶性不变则一边k个,另一边n-k-1个
// 考虑:n偶数,奇偶组合,先手胜
// n奇数:奇数,奇数 / 偶数,偶数,先手败
// 考虑三条边相连:每次截下一个三角形,则n偶数,先手败,n奇数,先手胜
// 上面一条最开始写反了,因为只需要剪下n-3个三角形,改变了奇偶性
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<ll,ll>
#define il inline
#define fastio ios::sync_with_stdio(false), cin.tie(0)

#define Cat printf("JMcat Win\n");
#define pz printf("PZ Win\n");
const int N = 5e4+5;
int n;
int match[N];
int main(){
	fastio;
	cin >> n;
	int a, b, c;
	int cnt = 0;
	cin >> a >> b >> c;
	match[a]++, match[b]++, match[c]++;
	printf("tar %d %d %d\n", a, b, c);
	for(int i=2,u,v,w; i<n; i++){
		cin >> u >> v >> w;
		match[u]++, match[v]++, match[w]++;
		if((match[u]==2 && match[v]==2) || (match[u]==2 && match[w]==2) 
			|| (match[v]==2 && match[w]==2)){
			printf("%d %d %d\n", u, v, w);
			cnt++;
		}
		match[u]--, match[v]--, match[w]--;
	}
	if(cnt==1){
		Cat;
		return 0;
	}
	else if(cnt==2){
		if(n & 1) {
			pz;
			return 0;
		}
		else{
			Cat;
			return 0;
		}
	}
	else if(cnt==3){
		if(n & 1){
			pz;
			return 0;
		}
		else{
			Cat;
			return 0;
		}
	}
	// 怎么会有四条边相连
	return 0;
}

输出数据
tar 10000 10002 10004
10001 10002 10000
10003 10004 10002
6387 10000 10004
6387 10000 10004\

拜谢各位dalao!

2024/7/21 23:27
加载中...