-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomfortablecows.cpp
More file actions
81 lines (60 loc) · 1.6 KB
/
comfortablecows.cpp
File metadata and controls
81 lines (60 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> x;
vector<int> y;
int n;
int x1,y1;
int x2, y2;
int x3, y3;
int count;
int temp;
int total = 0;
bool notfound;
cin>>n;
for(int c = 0;c<n;c++){
total = 0;
count = 0;
cin>>x2>>y2;
x.push_back(x2);
y.push_back(y2);
for (int i = 0;i<x.size();i++) {
count = 0;
x1 = x[i];
x2 = x[i]-1;
x3 = x[i]+1;
y1 = y[i];
y2 = y[i]-1;
y3 = y[i]+1;
try{
for(int j = 0;j<x.size();j++){
if(x[j]==x1){
if(y[j]==y2){
count++;
}
if(y[j]==y3){
count++;
}
}
if(x[j]==x2){
if(y[j]==y1){
count++;
}
}
if(x[j]==x3){
if(y[j]==y1){
count++;
}
}
}
temp = x[x1]+y[y1];
}catch(out_of_range const&){
notfound = true;
}
if(count==3){
total++;
}
}
cout<<total<<endl;
}
}