64762023-12-04 09:33:25KaukazusBináris Sakkcpp17Wrong answer 0/1002.099s8668 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

ll komponensek;
vector<pair<ll,ll>> helyek;
vector<ll> szulo;
vector<ll> meret;


bool fgv(ll a, ll b, ll c, ll d){
	//cerr << a << " " << b << " " << c << " " << d << endl;
	if(a==c || b==d || a-c==b-d){
		return true;
	}
	if(c==b && a==d){
		return true;
	}
	return false;
}

ll hol_van(ll a){
	if(szulo[a]==a){
		return a;
	}
	return hol_van(szulo[a]);
}


int main() {

	ios::sync_with_stdio(0);
	cin.tie(0); 
	cout.tie(0);

	ll R, N, C;
	cin >> R >> C >> N;

	
	szulo.resize(N+1);
	meret.resize(N+1);

	komponensek=N;

	for(ll i=1;i<N+1;i++){
		szulo[i]=i;
		meret[i]=1;
	}
	for(ll i=1;i<N+1;i++){
		pair<ll,ll> val;
		cin >> val.first >> val.second;
		helyek.push_back(val);
		//cerr <<"************************************** " <<   endl;
		for(ll j=0;j<i-1;j++){
			
			/*for(int x=0;x<helyek.size();x++){
				cerr << helyek[x].first << " " << helyek[x].second << endl;

			}
			cerr << endl << endl;*/
			if(fgv(helyek[j].first,helyek[j].second,val.first,val.second)){
				//cerr << "sikerr" << endl;
				//unio
				ll a=hol_van(i+1),b=hol_van(i);
				
				if(meret[a]<meret[b]) swap(a,b);
				
				meret[a]+=meret[b];
				szulo[b]=a;
				//
				komponensek--;
			}
		}

	}
	//cerr << komponensek;
	ll szam=pow(10,9)+7, hahh=pow(2,komponensek);
	cout << hahh%szam;

}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1888 KiB
2Accepted3ms2080 KiB
subtask20/11
3Accepted2ms2172 KiB
4Accepted3ms2292 KiB
5Wrong answer3ms2516 KiB
6Accepted3ms2732 KiB
7Accepted3ms2800 KiB
8Wrong answer3ms2832 KiB
9Wrong answer3ms2840 KiB
10Wrong answer4ms3172 KiB
11Wrong answer4ms3128 KiB
12Wrong answer4ms3132 KiB
13Wrong answer4ms3088 KiB
14Wrong answer6ms3360 KiB
15Wrong answer6ms3564 KiB
16Wrong answer6ms3876 KiB
17Wrong answer4ms4076 KiB
18Wrong answer3ms4008 KiB
subtask30/19
19Time limit exceeded2.099s5712 KiB
20Wrong answer481ms5804 KiB
21Wrong answer326ms5760 KiB
22Time limit exceeded2.073s7656 KiB
23Wrong answer1.159s7444 KiB
24Runtime error128ms5292 KiB
25Time limit exceeded2.055s7760 KiB
26Time limit exceeded2.073s7736 KiB
27Time limit exceeded2.082s7772 KiB
28Time limit exceeded2.049s7972 KiB
29Time limit exceeded2.071s8040 KiB
30Time limit exceeded2.078s8016 KiB
31Time limit exceeded2.069s8044 KiB
32Time limit exceeded2.062s8000 KiB
subtask40/19
33Wrong answer4ms4868 KiB
34Wrong answer4ms4872 KiB
35Accepted3ms4720 KiB
36Wrong answer3ms4832 KiB
37Wrong answer3ms4848 KiB
38Wrong answer3ms5108 KiB
39Wrong answer4ms5088 KiB
40Wrong answer4ms5176 KiB
41Wrong answer4ms5032 KiB
42Wrong answer4ms4984 KiB
43Wrong answer6ms5044 KiB
44Wrong answer6ms5160 KiB
45Wrong answer6ms5168 KiB
46Wrong answer4ms5088 KiB
47Wrong answer4ms5084 KiB
subtask50/51
48Wrong answer245ms6200 KiB
49Wrong answer1.531s8484 KiB
50Time limit exceeded2.075s7488 KiB
51Time limit exceeded2.066s7940 KiB
52Time limit exceeded2.071s6656 KiB
53Time limit exceeded2.078s6728 KiB
54Wrong answer1.422s8308 KiB
55Wrong answer182ms6144 KiB
56Wrong answer1.368s8336 KiB
57Time limit exceeded2.022s8440 KiB
58Time limit exceeded2.017s8440 KiB
59Time limit exceeded2.062s8456 KiB
60Time limit exceeded2.04s8388 KiB
61Time limit exceeded2.065s8452 KiB
62Time limit exceeded2.066s8568 KiB
63Time limit exceeded2.069s8000 KiB
64Time limit exceeded2.053s7880 KiB
65Time limit exceeded2.073s8044 KiB
66Time limit exceeded2.029s8488 KiB
67Time limit exceeded2.071s8544 KiB
68Time limit exceeded2.059s8668 KiB