-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.cpp
More file actions
74 lines (69 loc) · 1.36 KB
/
Copy pathtemplate.cpp
File metadata and controls
74 lines (69 loc) · 1.36 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
#include <bits/stdc++.h>
using namespace std;
int main() {
ifstream fin("_.in");
ofstream fout("_.out");
int n;
cin >> n;
int _[n];
for (int i=0; i<n; i++) {
cin >> _[i];
}
pair<int,int> _[n];
//tuple<int,int,int> _[n];
for (int i=0; i<n; i++) {
cin >> _[i];
}
int _[n][m];
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
cin >> _[i][j];
}
}
int result=0;
cout << result << "\n";
return 0;
}
//for dfs/flood fill
bool visited[n];
for (int i=0; i<n; i++) {
visited[i]=false;
}
//depth first search
void dfs(bool visited[],vector<int> adjacent[],int _) {
visited[_]=true;
for (int _: adjacent[_]) {
if (not visited[_]) {
dfs(visited,adjacent,_);
}
}
}
//flood fill
void ff(bool visited[],int i,int j) {
visited[i*n+j]=true;
if (i!=0 && not visited[(i-1)*n+j]) {
ff(visited,i-1,j);
}
if (i!=n-1 && not visited[(i+1)*n+j]) {
ff(visited,i+1,j);
}
if (j!=0 && not visited[i*n+j-1]) {
ff(visited,i,j-1);
}
if (j!=n-1 && not visited[i*n+j+1]) {
ff(visited,i,j+1);
}
}
//binary search on the answer
int bs() {
int l=0,r=_,m;
while (l<r) {
m=(l+r)/2;
if (_(m)) {
l=m+1;
} else {
r=m;
}
}
return l;
}