6476 | 2023-12-04 09:33:25 | Kaukazus | Bináris Sakk | cpp17 | Wrong answer 0/100 | 2.099s | 8668 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1888 KiB | ||||
2 | Accepted | 3ms | 2080 KiB | ||||
subtask2 | 0/11 | ||||||
3 | Accepted | 2ms | 2172 KiB | ||||
4 | Accepted | 3ms | 2292 KiB | ||||
5 | Wrong answer | 3ms | 2516 KiB | ||||
6 | Accepted | 3ms | 2732 KiB | ||||
7 | Accepted | 3ms | 2800 KiB | ||||
8 | Wrong answer | 3ms | 2832 KiB | ||||
9 | Wrong answer | 3ms | 2840 KiB | ||||
10 | Wrong answer | 4ms | 3172 KiB | ||||
11 | Wrong answer | 4ms | 3128 KiB | ||||
12 | Wrong answer | 4ms | 3132 KiB | ||||
13 | Wrong answer | 4ms | 3088 KiB | ||||
14 | Wrong answer | 6ms | 3360 KiB | ||||
15 | Wrong answer | 6ms | 3564 KiB | ||||
16 | Wrong answer | 6ms | 3876 KiB | ||||
17 | Wrong answer | 4ms | 4076 KiB | ||||
18 | Wrong answer | 3ms | 4008 KiB | ||||
subtask3 | 0/19 | ||||||
19 | Time limit exceeded | 2.099s | 5712 KiB | ||||
20 | Wrong answer | 481ms | 5804 KiB | ||||
21 | Wrong answer | 326ms | 5760 KiB | ||||
22 | Time limit exceeded | 2.073s | 7656 KiB | ||||
23 | Wrong answer | 1.159s | 7444 KiB | ||||
24 | Runtime error | 128ms | 5292 KiB | ||||
25 | Time limit exceeded | 2.055s | 7760 KiB | ||||
26 | Time limit exceeded | 2.073s | 7736 KiB | ||||
27 | Time limit exceeded | 2.082s | 7772 KiB | ||||
28 | Time limit exceeded | 2.049s | 7972 KiB | ||||
29 | Time limit exceeded | 2.071s | 8040 KiB | ||||
30 | Time limit exceeded | 2.078s | 8016 KiB | ||||
31 | Time limit exceeded | 2.069s | 8044 KiB | ||||
32 | Time limit exceeded | 2.062s | 8000 KiB | ||||
subtask4 | 0/19 | ||||||
33 | Wrong answer | 4ms | 4868 KiB | ||||
34 | Wrong answer | 4ms | 4872 KiB | ||||
35 | Accepted | 3ms | 4720 KiB | ||||
36 | Wrong answer | 3ms | 4832 KiB | ||||
37 | Wrong answer | 3ms | 4848 KiB | ||||
38 | Wrong answer | 3ms | 5108 KiB | ||||
39 | Wrong answer | 4ms | 5088 KiB | ||||
40 | Wrong answer | 4ms | 5176 KiB | ||||
41 | Wrong answer | 4ms | 5032 KiB | ||||
42 | Wrong answer | 4ms | 4984 KiB | ||||
43 | Wrong answer | 6ms | 5044 KiB | ||||
44 | Wrong answer | 6ms | 5160 KiB | ||||
45 | Wrong answer | 6ms | 5168 KiB | ||||
46 | Wrong answer | 4ms | 5088 KiB | ||||
47 | Wrong answer | 4ms | 5084 KiB | ||||
subtask5 | 0/51 | ||||||
48 | Wrong answer | 245ms | 6200 KiB | ||||
49 | Wrong answer | 1.531s | 8484 KiB | ||||
50 | Time limit exceeded | 2.075s | 7488 KiB | ||||
51 | Time limit exceeded | 2.066s | 7940 KiB | ||||
52 | Time limit exceeded | 2.071s | 6656 KiB | ||||
53 | Time limit exceeded | 2.078s | 6728 KiB | ||||
54 | Wrong answer | 1.422s | 8308 KiB | ||||
55 | Wrong answer | 182ms | 6144 KiB | ||||
56 | Wrong answer | 1.368s | 8336 KiB | ||||
57 | Time limit exceeded | 2.022s | 8440 KiB | ||||
58 | Time limit exceeded | 2.017s | 8440 KiB | ||||
59 | Time limit exceeded | 2.062s | 8456 KiB | ||||
60 | Time limit exceeded | 2.04s | 8388 KiB | ||||
61 | Time limit exceeded | 2.065s | 8452 KiB | ||||
62 | Time limit exceeded | 2.066s | 8568 KiB | ||||
63 | Time limit exceeded | 2.069s | 8000 KiB | ||||
64 | Time limit exceeded | 2.053s | 7880 KiB | ||||
65 | Time limit exceeded | 2.073s | 8044 KiB | ||||
66 | Time limit exceeded | 2.029s | 8488 KiB | ||||
67 | Time limit exceeded | 2.071s | 8544 KiB | ||||
68 | Time limit exceeded | 2.059s | 8668 KiB |