64862023-12-04 22:10:10KaukazusBináris Sakkcpp17Wrong answer 0/1002.099s8596 KiB
#include <bits/stdc++.h>
//#include <cmath>
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 || abs(a-c)==abs(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
1Accepted3ms1768 KiB
2Accepted3ms1928 KiB
subtask20/11
3Accepted3ms2140 KiB
4Accepted3ms2372 KiB
5Wrong answer3ms2580 KiB
6Accepted3ms2804 KiB
7Accepted3ms3020 KiB
8Wrong answer3ms3132 KiB
9Wrong answer3ms3128 KiB
10Wrong answer4ms3436 KiB
11Wrong answer4ms3636 KiB
12Wrong answer4ms3676 KiB
13Wrong answer4ms3528 KiB
14Wrong answer6ms3580 KiB
15Wrong answer6ms3576 KiB
16Wrong answer6ms3572 KiB
17Wrong answer6ms3836 KiB
18Wrong answer3ms3832 KiB
subtask30/19
19Time limit exceeded2.099s5568 KiB
20Wrong answer563ms5684 KiB
21Wrong answer374ms5708 KiB
22Time limit exceeded2.062s7332 KiB
23Wrong answer1.358s7316 KiB
24Runtime error145ms5248 KiB
25Time limit exceeded2.055s7872 KiB
26Time limit exceeded2.071s7684 KiB
27Time limit exceeded2.075s7740 KiB
28Time limit exceeded2.078s7916 KiB
29Time limit exceeded2.062s8056 KiB
30Time limit exceeded2.082s7820 KiB
31Time limit exceeded2.073s7868 KiB
32Time limit exceeded2.099s7760 KiB
subtask40/19
33Wrong answer4ms4560 KiB
34Wrong answer4ms4844 KiB
35Accepted3ms5048 KiB
36Wrong answer3ms5036 KiB
37Wrong answer3ms4940 KiB
38Wrong answer3ms5000 KiB
39Wrong answer4ms4924 KiB
40Wrong answer4ms4924 KiB
41Wrong answer4ms4928 KiB
42Wrong answer4ms4864 KiB
43Wrong answer6ms4872 KiB
44Wrong answer6ms4924 KiB
45Wrong answer6ms4908 KiB
46Wrong answer6ms4916 KiB
47Wrong answer4ms4864 KiB
subtask50/51
48Wrong answer273ms5936 KiB
49Wrong answer1.72s8204 KiB
50Time limit exceeded2.019s7384 KiB
51Time limit exceeded2.082s7896 KiB
52Time limit exceeded2.072s6328 KiB
53Time limit exceeded2.046s6688 KiB
54Wrong answer1.598s8316 KiB
55Wrong answer204ms6044 KiB
56Wrong answer1.539s8260 KiB
57Time limit exceeded2.059s8356 KiB
58Time limit exceeded2.051s8428 KiB
59Time limit exceeded2.085s8540 KiB
60Time limit exceeded2.062s8416 KiB
61Time limit exceeded2.061s8416 KiB
62Time limit exceeded2.075s8412 KiB
63Time limit exceeded2.062s8048 KiB
64Time limit exceeded2.071s7908 KiB
65Time limit exceeded2.062s7928 KiB
66Time limit exceeded2.059s7808 KiB
67Time limit exceeded2.049s8304 KiB
68Time limit exceeded2.049s8596 KiB