結果

問題 No.2274 三角彩色
ユーザー 沙耶花沙耶花
提出日時 2023-04-14 22:47:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,379 bytes
コンパイル時間 5,431 ms
コンパイル使用メモリ 262,032 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 20:22:03
合計ジャッジ時間 5,343 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

void Gauss(vector<bitset<405>> &B){
	int now = 0;
	rep(i,405){
		int temp = -1;
		for(int j=now;j<B.size();j++){
			if(B[j][i]){
				temp = j;
				break;
			}
		}
		if(temp==-1)continue;
		
		rep(j,B.size()){
			if(temp==j)continue;
			if(B[j][i])B[j] ^= B[temp];
		}
		
		swap(B[now],B[temp]);
		now++;
	}
}

int main(){
	
	long long n,m,b,q;
	cin>>n>>m>>b>>q;
	
	vector<long long> u(m),v(m);
	vector<long long> t;
	rep(i,m){
		cin>>u[i]>>v[i];
		t.push_back(u[i]);
		t.push_back(v[i]);
	}
	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	rep(i,m){
		u[i] = distance(t.begin(),lower_bound(t.begin(),t.end(),u[i]));
		v[i] = distance(t.begin(),lower_bound(t.begin(),t.end(),v[i]));
	}
	
	dsu D(t.size());
	long long cnt = 0;
	rep(i,m){
		if(D.same(u[i],v[i]))cnt++;
		else D.merge(u[i],v[i]);
	}
	
	vector<bitset<405>> Bs(q);
	rep(i,q){
		int x,y,z;cin>>x>>y>>z;
		Bs[i][x]  =1;
		Bs[i][y]  =1;
		Bs[i][z]  =1;
	}
	
	Gauss(Bs);
	long long T = 1;
	rep(i,Bs.size()){
		T *= 2;
		T %= b;
	}
	long long S = 1;
	rep(i,cnt){
		S *= 2;
		S %= b;
	}
	S -= T;
	if(S<0)S += b;
	S %= b;
	cout<<S<<' '<<T<<endl;
	
	return 0;
}
0