QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#570747#9310. Permutation Counting 4TTTklWA 0ms3788kbC++231.1kb2024-09-17 17:31:442024-09-17 17:31:44

Judging History

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

  • [2024-09-18 14:56:40]
  • hack成功,自动添加数据
  • (/hack/835)
  • [2024-09-18 14:41:06]
  • hack成功,自动添加数据
  • (/hack/831)
  • [2024-09-17 17:31:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3788kb
  • [2024-09-17 17:31:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef basic_string<int> BI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1010000;
int f[N],n;
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
void solve() {
	scanf("%d",&n);
	rep(i,0,n+1) f[i]=i;
	bool val=1;
	rep(i,1,n+1) {
		int l,r;
		scanf("%d%d",&l,&r);
		//--l;
		if (find(l)==find(r)) val=0;
		else f[find(l)]=find(r);
	}
	printf("%d\n",val);
}

int _;
int main() {
	for (scanf("%d",&_);_;_--) {
		solve();
	}
}

详细

Test #1:

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

input:

4
5
1 2
1 5
1 2
1 2
2 2
5
1 1
2 4
2 3
5 5
3 4
5
3 5
1 2
3 4
3 5
3 3
5
1 5
1 4
4 5
5 5
1 2

output:

0
0
0
0

result:

wrong answer 2nd words differ - expected: '1', found: '0'