Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- bool t[9][9],C[9][9];
- int main()
- {
- ifstream f ("bpj2020.in");
- int n,a,l,c,s=0;
- f>>n;
- while(n--)
- {
- f>>a>>l>>c;
- if(a<=5)
- {
- s=s+a;
- for(int j=c;j<=c+a-1;++j)
- t[l][j]=1;
- }
- else if(a==6)
- {
- s=s+4;
- t[l][c]=1;
- t[l][c+1]=1;
- t[l+1][c]=1;
- t[l+1][c+1]=1;
- }
- else if(a==7)
- {
- s=s+9;
- t[l][c]=1;
- t[l][c+1]=1;
- t[l][c+2]=1;
- t[l+1][c]=1;
- t[l+1][c+1]=1;
- t[l+1][c+2]=1;
- t[l+2][c]=1;
- t[l+2][c+1]=1;
- t[l+2][c+2]=1;
- }
- else if(a<=11)
- {
- s=s+a-7+1;
- for(int j=l;j<=l+a-7;++j)
- t[j][c]=1;
- }
- else if(a==12)
- {
- s=s+3;
- t[l][c]=1;
- t[l+1][c]=1;
- t[l][c+1]=1;
- }
- else if(a==13)
- {
- s=s+4;
- t[l][c]=1;
- t[l+1][c-1]=1;
- t[l+1][c]=1;
- t[l+1][c+1]=1;
- }
- else if(a==14)
- {
- s=s+4;
- t[l][c]=1;
- t[l+1][c]=1;
- t[l+1][c+1]=1;
- t[l+2][c+1]=1;
- }
- else if(a==15)
- {
- s=s+4;
- t[l][c]=1;
- t[l][c+1]=1;
- t[l+1][c-1]=1;
- t[l+1][c]=1;
- }
- else if(a==16)
- {
- s=s+5;
- t[l][c]=1;
- t[l][c+1]=1;
- t[l][c+2]=1;
- t[l+1][c+2]=1;
- t[l+2][c+2]=1;
- }
- else if(a==17)
- {
- s=s+4;
- t[l][c]=1;
- t[l+1][c]=1;
- t[l+1][c+1]=1;
- t[l+1][c+2]=1;
- }
- int rand_elim=0;
- for(int i=1;i<=8;++i)
- {
- for(int j=1;j<=8;++j)
- C[i][j]=t[i][j];
- }
- for(int i=1;i<=8;++i)
- {
- int cnt=0;
- for(int j=1;j<=8;++j)
- {
- if(t[i][j]==1)
- cnt++;
- }
- if(cnt>=8)
- {
- rand_elim++;
- for(int j=1;j<=8;++j)
- {
- C[i][j]=0;
- }
- }
- }
- for(int j=1;j<=8;++j)
- {
- int cnt=0;
- for(int i=1;i<=8;++i)
- {
- if(t[i][j]==1)
- cnt++;
- }
- if(cnt>=8)
- {
- rand_elim++;
- for(int i=1;i<=8;++i)
- {
- C[i][j]=0;
- }
- }
- }
- if(rand_elim==1)
- s+=10;
- else if(rand_elim==2)
- s+=30;
- else if(rand_elim==3)
- s+=60;
- else if(rand_elim==4)
- s+=100;
- else if(rand_elim==5)
- s+=150;
- else if(rand_elim==6)
- s+=500;
- for(int i=1;i<=8;++i)
- {
- for(int j=1;j<=8;++j)
- {
- if(C[i][j]==0)
- t[i][j]=0;
- }
- }
- }
- f.close();
- ofstream g("bpj2020.out");
- g<<s;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement