Add new attachment

Only authorized users are allowed to upload new attachments.

This page (revision-4) was last changed on 20-Aug-2015 17:35 by bedzo

This page was created on 20-Aug-2015 17:35 by FREEZX

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 2 added one line
!!Коцки:
At line 4 added 54 lines
!C++
%%prettify
{{{
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int m,n,b;
cin>>m>>n;
b=min(m,n);
if(b%2!=0) b--;
cout<<b*b;
return 0;
}
}}}
/%
!!Озборување:
!C++
%%prettify
{{{
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
int m,n,i,j,a,b,max=0,cur;
bool mat[101][101];
memset(mat,false,sizeof(mat));
cin>>m>>n;
for(i=1;i<=m;i++) mat[i][i]=true;
for(i=0;i<n;i++){
cin>>a>>b;
for(j=1;j<=m;j++) if(mat[j][a] || mat[j][b]) mat[j][a]=mat[j][b]=true;
}
for(i=1;i<=m;i++){
cur=0;
for(j=1;j<=m;j++) if(mat[j][i]) cur++;
if(cur>max) max=cur;
}
cout<<max-1;
return 0;
}
}}}
/%
-- Филип Беџовски
At line 306 added 72 lines
--Кристијан Трајковски
!!Финкимен co breadth first search(bfs):
!C++
%%prettify
{{{
#include <iostream>
#include<queue>
using namespace std;
int mat[51][51],n,m,iii,jjj,miin=99999,mat2[51][51]={0};
bool check(){
for(int i=0;i<n;i++) for(int j=0;j<m;j++) if(mat2[i][j]==0) return false;
return true;
}
void miiin(){
for(int i=0;i<n;i++) for(int j=0;j<m;j++) if(mat[i][j]<miin && mat2[i][j]!=1){
miin=mat[i][j];
iii=i;
jjj=j;
}
}
int main()
{
int i,j,I,J,sum=0,pom;
cin>>n>>m;
queue<int> qi,qj;
for(i=0;i<n;i++) for(j=0;j<m;j++) cin>>mat[i][j];
while(!check()){
miiin();
sum++;
qi.push(iii);
qj.push(jjj);
mat2[iii][jjj]=1;
while(!qi.empty()){
I=qi.front();
J=qj.front();
qi.pop();
qj.pop();
pom=mat[I][J];
if(mat2[I][J+1]==0 && mat[I][J+1]>=pom && J+1<=m){ //desno
qi.push(I);
qj.push(J+1);
mat2[I][J+1]=1;
}
if(mat2[I][J-1]==0 && mat[I][J-1]>=pom && J-1>=0){ // levo
qi.push(I);
qj.push(J-1);
mat2[I][J-1]=1;
}
if(mat2[I+1][J]!=1 && mat[I+1][J]>=pom && I+1<=n){ //dole
qi.push(I+1);
qj.push(J);
mat2[I+1][J]=1;
}
if(mat2[I-1][J]!=1 && mat[I-1][J]>=pom && I-1>=0){//gore
qi.push(I-1);
qj.push(J);
mat2[I-1][J]=1;
}
}
miin=99999;
}
cout<<sum;
return 0;
}
}}}
/%
-- Филип Беџовски
Version Date Modified Size Author Changes ... Change note
4 20-Aug-2015 17:35 6.626 kB bedzo to previous
3 20-Aug-2015 17:35 5.787 kB bedzo to previous | to last
2 20-Aug-2015 17:35 4.378 kB FREEZX to previous | to last
1 20-Aug-2015 17:35 4.354 kB FREEZX to last
« This page (revision-4) was last changed on 20-Aug-2015 17:35 by bedzo