Skip to content

Commit

Permalink
Keteki Power Match 2
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypotter0 committed Feb 20, 2018
1 parent a078283 commit bd60a07
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CP/Codeforces Round #465 (Div. 2)/prob1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
n = int(input())
c = 0
for i in range(1,n/2+1):
if((n-i)%i==0):
c+=1
# print(n-i,i,"love")
print(c)
Empty file.
Empty file.
7 changes: 0 additions & 7 deletions CP/February Cook-Off 2018/prob3.py

This file was deleted.

Empty file.
Empty file.
44 changes: 44 additions & 0 deletions CP/Keteki Power Match 2/prob3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include<bits/stdc++.h>
using namespace std;
#define pb push_back

int main(){
int i,j,a[10][10],counter,n,m,x,y,t;
cin>>t;
while(t--){
int vis[10][10]={0};
cin>>n>>m;

for(i=0;i<n;i++){
for(j=0;j<m;j++)
cin>>a[i][j];
}

for(i=0,counter=1;i<n;i++){
for(j=0;j<m;j++){
if(!vis[i][j]){
deque<pair<int,int>> d;
d.pb({i,j});
while (!d.empty()) {
x = d.front().first;
y = d.front().second;
d.pop_front();
vis[x][y] = counter;
if(x>0 && !vis[x-1][y] && a[x-1][y]==a[x][y])
d.pb({x-1,y});
if(y>0 && !vis[x][y-1] && a[x][y-1]==a[x][y])
d.pb({x,y-1});
if(x<n && !vis[x+1][y] && a[x+1][y]==a[x][y])
d.pb({x+1,y});
if(y<m && !vis[x][y+1] && a[x][y+1]==a[x][y])
d.pb({x,y+1});
}
counter++;
}
}
}

cout<<(counter-1)<<"\n";
}
return 0;
}

0 comments on commit bd60a07

Please sign in to comment.