Skip to content

Commit bd60a07

Browse files
committed
Keteki Power Match 2
1 parent a078283 commit bd60a07

File tree

7 files changed

+51
-7
lines changed

7 files changed

+51
-7
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
n = int(input())
2+
c = 0
3+
for i in range(1,n/2+1):
4+
if((n-i)%i==0):
5+
c+=1
6+
# print(n-i,i,"love")
7+
print(c)

CP/Codeforces Round #465 (Div. 2)/prob2.py

Whitespace-only changes.

CP/February Cook-Off 2018/prob3.cpp

Whitespace-only changes.

CP/February Cook-Off 2018/prob3.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

CP/February Cook-Off 2018/prob4.cpp

Whitespace-only changes.

CP/February Cook-Off 2018/prob5.cpp

Whitespace-only changes.

CP/Keteki Power Match 2/prob3.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
#define pb push_back
4+
5+
int main(){
6+
int i,j,a[10][10],counter,n,m,x,y,t;
7+
cin>>t;
8+
while(t--){
9+
int vis[10][10]={0};
10+
cin>>n>>m;
11+
12+
for(i=0;i<n;i++){
13+
for(j=0;j<m;j++)
14+
cin>>a[i][j];
15+
}
16+
17+
for(i=0,counter=1;i<n;i++){
18+
for(j=0;j<m;j++){
19+
if(!vis[i][j]){
20+
deque<pair<int,int>> d;
21+
d.pb({i,j});
22+
while (!d.empty()) {
23+
x = d.front().first;
24+
y = d.front().second;
25+
d.pop_front();
26+
vis[x][y] = counter;
27+
if(x>0 && !vis[x-1][y] && a[x-1][y]==a[x][y])
28+
d.pb({x-1,y});
29+
if(y>0 && !vis[x][y-1] && a[x][y-1]==a[x][y])
30+
d.pb({x,y-1});
31+
if(x<n && !vis[x+1][y] && a[x+1][y]==a[x][y])
32+
d.pb({x+1,y});
33+
if(y<m && !vis[x][y+1] && a[x][y+1]==a[x][y])
34+
d.pb({x,y+1});
35+
}
36+
counter++;
37+
}
38+
}
39+
}
40+
41+
cout<<(counter-1)<<"\n";
42+
}
43+
return 0;
44+
}

0 commit comments

Comments
 (0)