6486 | 2023-12-04 22:10:10 | Kaukazus | Bináris Sakk | cpp17 | Wrong answer 0/100 | 2.099s | 8596 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1768 KiB | ||||
2 | Accepted | 3ms | 1928 KiB | ||||
subtask2 | 0/11 | ||||||
3 | Accepted | 3ms | 2140 KiB | ||||
4 | Accepted | 3ms | 2372 KiB | ||||
5 | Wrong answer | 3ms | 2580 KiB | ||||
6 | Accepted | 3ms | 2804 KiB | ||||
7 | Accepted | 3ms | 3020 KiB | ||||
8 | Wrong answer | 3ms | 3132 KiB | ||||
9 | Wrong answer | 3ms | 3128 KiB | ||||
10 | Wrong answer | 4ms | 3436 KiB | ||||
11 | Wrong answer | 4ms | 3636 KiB | ||||
12 | Wrong answer | 4ms | 3676 KiB | ||||
13 | Wrong answer | 4ms | 3528 KiB | ||||
14 | Wrong answer | 6ms | 3580 KiB | ||||
15 | Wrong answer | 6ms | 3576 KiB | ||||
16 | Wrong answer | 6ms | 3572 KiB | ||||
17 | Wrong answer | 6ms | 3836 KiB | ||||
18 | Wrong answer | 3ms | 3832 KiB | ||||
subtask3 | 0/19 | ||||||
19 | Time limit exceeded | 2.099s | 5568 KiB | ||||
20 | Wrong answer | 563ms | 5684 KiB | ||||
21 | Wrong answer | 374ms | 5708 KiB | ||||
22 | Time limit exceeded | 2.062s | 7332 KiB | ||||
23 | Wrong answer | 1.358s | 7316 KiB | ||||
24 | Runtime error | 145ms | 5248 KiB | ||||
25 | Time limit exceeded | 2.055s | 7872 KiB | ||||
26 | Time limit exceeded | 2.071s | 7684 KiB | ||||
27 | Time limit exceeded | 2.075s | 7740 KiB | ||||
28 | Time limit exceeded | 2.078s | 7916 KiB | ||||
29 | Time limit exceeded | 2.062s | 8056 KiB | ||||
30 | Time limit exceeded | 2.082s | 7820 KiB | ||||
31 | Time limit exceeded | 2.073s | 7868 KiB | ||||
32 | Time limit exceeded | 2.099s | 7760 KiB | ||||
subtask4 | 0/19 | ||||||
33 | Wrong answer | 4ms | 4560 KiB | ||||
34 | Wrong answer | 4ms | 4844 KiB | ||||
35 | Accepted | 3ms | 5048 KiB | ||||
36 | Wrong answer | 3ms | 5036 KiB | ||||
37 | Wrong answer | 3ms | 4940 KiB | ||||
38 | Wrong answer | 3ms | 5000 KiB | ||||
39 | Wrong answer | 4ms | 4924 KiB | ||||
40 | Wrong answer | 4ms | 4924 KiB | ||||
41 | Wrong answer | 4ms | 4928 KiB | ||||
42 | Wrong answer | 4ms | 4864 KiB | ||||
43 | Wrong answer | 6ms | 4872 KiB | ||||
44 | Wrong answer | 6ms | 4924 KiB | ||||
45 | Wrong answer | 6ms | 4908 KiB | ||||
46 | Wrong answer | 6ms | 4916 KiB | ||||
47 | Wrong answer | 4ms | 4864 KiB | ||||
subtask5 | 0/51 | ||||||
48 | Wrong answer | 273ms | 5936 KiB | ||||
49 | Wrong answer | 1.72s | 8204 KiB | ||||
50 | Time limit exceeded | 2.019s | 7384 KiB | ||||
51 | Time limit exceeded | 2.082s | 7896 KiB | ||||
52 | Time limit exceeded | 2.072s | 6328 KiB | ||||
53 | Time limit exceeded | 2.046s | 6688 KiB | ||||
54 | Wrong answer | 1.598s | 8316 KiB | ||||
55 | Wrong answer | 204ms | 6044 KiB | ||||
56 | Wrong answer | 1.539s | 8260 KiB | ||||
57 | Time limit exceeded | 2.059s | 8356 KiB | ||||
58 | Time limit exceeded | 2.051s | 8428 KiB | ||||
59 | Time limit exceeded | 2.085s | 8540 KiB | ||||
60 | Time limit exceeded | 2.062s | 8416 KiB | ||||
61 | Time limit exceeded | 2.061s | 8416 KiB | ||||
62 | Time limit exceeded | 2.075s | 8412 KiB | ||||
63 | Time limit exceeded | 2.062s | 8048 KiB | ||||
64 | Time limit exceeded | 2.071s | 7908 KiB | ||||
65 | Time limit exceeded | 2.062s | 7928 KiB | ||||
66 | Time limit exceeded | 2.059s | 7808 KiB | ||||
67 | Time limit exceeded | 2.049s | 8304 KiB | ||||
68 | Time limit exceeded | 2.049s | 8596 KiB |