Submission #956596

# Submission time Handle Problem Language Result Execution time Memory
956596 2024-04-02T08:11:15 Z MrBrionix Costinland (info1cup19_costinland) C++17
100 / 100
1 ms 600 KB
#include<bits/stdc++.h>
using namespace std;

long long k,pos=0,tmp;
char mat[100][100];

void f1(){
    
    for(int i=pos;i<pos+4;i++)for(int j=pos;j<pos+4;j++)mat[i][j]='X';
    
    mat[pos+1][pos+2]=mat[pos+2][pos+1]=mat[pos+2][pos+2]='.';
    
    for(int i=0;i<4;i++)mat[pos+4][pos+i]='r';
    for(int i=0;i<4;i++)mat[pos+i][pos+4]='d';
    
    if(tmp&1)mat[pos+4][pos]='X';
    if(tmp&4)mat[pos+4][pos+1]='X';
    if(tmp&8)mat[pos+4][pos+2]='X';
    if(tmp&16)mat[pos+4][pos+3]='X';
    
    if(tmp&2){
        mat[pos][pos+4]='X';
        mat[pos][pos+5]='X';
        mat[pos+1][pos+5]='r';
    }
    
}

void f2(){
    
    int tmp2=pos,cont2=0,init=tmp;
    
    while(tmp && cont2<4){
        
        if(tmp%2==0){
            mat[tmp2][tmp2]='X';
            mat[tmp2+1][tmp2]='r';
            mat[tmp2][tmp2+1]='d';
        }
        else{
            if(tmp/2==0)mat[tmp2][tmp2]='d';
            else{
                mat[tmp2][tmp2]='X';
                mat[tmp2+1][tmp2]='X';
                mat[tmp2][tmp2+1]='d';
            }
        }
        
        
        tmp/=2;
        tmp2++;
        cont2++;
    }
    
   
    
    if(tmp>0){
        
        if((init&8)==0)return;
        
        
        mat[tmp2-1][tmp2-1]='X';
        mat[tmp2-2][tmp2-1]='X';
        mat[tmp2-3][tmp2-2]='X';
        mat[tmp2-4][tmp2-3]='X';
        mat[tmp2-4][tmp2-1]='X';
        mat[tmp2-3][tmp2-1]='r';
    }
    
    return;
}

int main(){

	cin>>k;
	
	for(int i=0;i<100;i++)for(int j=0;j<100;j++)mat[i][j]='.';

    while(k){
        
        tmp=k%(32);
        k>>=5;
        
        if(k==0)f2();
        else f1();
        
        pos+=4;
    }
    
    for(int i=0;i<=pos;i++){
        mat[pos][i]='r';
        mat[i][pos]='d';
    }
    mat[pos][pos]='.';
    
    cout<<pos+1<<" "<<pos+1<<"\n";
    for(int i=0;i<=pos;i++){
        for(int j=0;j<=pos;j++)cout<<mat[i][j];
        cout<<"\n";
    }
    
    

return 0;
}

Compilation message

costinland.cpp: In function 'void f1()':
costinland.cpp:11:58: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   11 |     mat[pos+1][pos+2]=mat[pos+2][pos+1]=mat[pos+2][pos+2]='.';
      |                                         ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:11:40: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   11 |     mat[pos+1][pos+2]=mat[pos+2][pos+1]=mat[pos+2][pos+2]='.';
      |                       ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:11:22: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   11 |     mat[pos+1][pos+2]=mat[pos+2][pos+1]=mat[pos+2][pos+2]='.';
      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:14:42: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   14 |     for(int i=0;i<4;i++)mat[pos+i][pos+4]='d';
      |                         ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:14:42: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   14 |     for(int i=0;i<4;i++)mat[pos+i][pos+4]='d';
      |                         ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:14:42: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   14 |     for(int i=0;i<4;i++)mat[pos+i][pos+4]='d';
      |                         ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:17:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   17 |     if(tmp&4)mat[pos+4][pos+1]='X';
      |              ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:18:31: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   18 |     if(tmp&8)mat[pos+4][pos+2]='X';
      |              ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:19:32: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   19 |     if(tmp&16)mat[pos+4][pos+3]='X';
      |               ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
costinland.cpp:24:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   24 |         mat[pos+1][pos+5]='r';
      |         ~~~~~~~~~~~~~~~~~^~~~
costinland.cpp:5:6: note: at offset 0 to object 'mat' with size 10000 declared here
    5 | char mat[100][100];
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Correct! Your size: 5
2 Correct 0 ms 348 KB Correct! Your size: 5
3 Correct 1 ms 348 KB Correct! Your size: 5
4 Correct 0 ms 348 KB Correct! Your size: 5
5 Correct 0 ms 348 KB Correct! Your size: 5
6 Correct 0 ms 344 KB Correct! Your size: 5
7 Correct 0 ms 348 KB Correct! Your size: 5
8 Correct 1 ms 344 KB Correct! Your size: 5
9 Correct 1 ms 348 KB Correct! Your size: 5
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Correct! Your size: 49
2 Correct 0 ms 348 KB Correct! Your size: 49
3 Correct 0 ms 348 KB Correct! Your size: 49
4 Correct 0 ms 344 KB Correct! Your size: 49
5 Correct 0 ms 348 KB Correct! Your size: 49
6 Correct 0 ms 348 KB Correct! Your size: 49
7 Correct 1 ms 600 KB Correct! Your size: 49
8 Correct 0 ms 348 KB Correct! Your size: 49