Submission #489614

# Submission time Handle Problem Language Result Execution time Memory
489614 2021-11-23T11:38:57 Z cadmiumsky Costinland (info1cup19_costinland) C++14
100 / 100
1 ms 336 KB
#include <iostream>
#include <vector>

using namespace std;
#define int long long // ma-ta si cu tac-tu(tactu?)
char mat[500][500]; // 49 lmao
vector<int> base;
  
void start(int x, int y) {
  int coef=base[0];
  if(base.size()==1) {
    switch(coef) {
      case 1:
        mat[x][y]='.';
        break;
      case 2:
        mat[x][y]='X';
        break;
      case 3:
        mat[x][y]='X';
        mat[x][y+1]='X';
        break;
      case 4:
        mat[x][y]='X';
        mat[x][y+1]='X';
        mat[x+1][y]='X';
        break;
      case 5:
        mat[x][y]='X';
        mat[x+1][y]='X';
        mat[x][y+1]='d';
        mat[x+1][y+1]='X';
        break;
    }
  }
  else {
    //cout << coef << '\n';
    base.erase(base.begin());
    mat[x][y]=mat[x+1][y+1]=mat[x+1][y]=mat[x][y+1]='X';
    x+=2;
    y+=2;
    mat[x-1][y]=mat[x-2][y]='d';
    mat[x][y-1]=mat[x][y-2]='r';
    switch(coef) { // escape characters
      case 1:
        mat[x][y-2]='X';
        break;
      case 2:
        mat[x][y-2]='X';
        mat[x-2][y]='X';
        break;
      case 3:
        mat[x][y-1]='X';
        break;
      case 4:
        mat[x-2][y]='X';
        mat[x-1][y]='X';
        break;
      case 5:
        mat[x][y-1]='X';
        mat[x-2][y]='X';
        mat[x][y-2]='X';
        break;
      default:
        break;
    }
    start(x,y);
  }
  return;
}
  
signed main() {
  int k,n;
  cin >> k;
  for(int i=0; i<60; i++) {
    for(int j=0; j<60; j++)
      mat[i][j]='.';
  }
  if(k<=19) {
    cout << "5 5\n";
    n=5;
  }
  else {
    cout << "49 49\n";
    n=49;
  }
  for(int i=0; i<n; i++)
    mat[i][n-1]='d',mat[n-1][i]='r';
  mat[n-1][n-1]='.';
  while(k) {
    base.push_back(k%6);
    k/=6;
  }
  start(0,0);
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) 
      cout << mat[i][j];
    cout << '\n';
  }
}

Compilation message

costinland.cpp: In function 'void start(long long int, long long int)':
costinland.cpp:32:22: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
   32 |         mat[x+1][y+1]='X';
      |         ~~~~~~~~~~~~~^~~~
costinland.cpp:6:6: note: at offset 0 to object 'mat' with size 250000 declared here
    6 | char mat[500][500]; // 49 lmao
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Correct! Your size: 5
2 Correct 0 ms 204 KB Correct! Your size: 5
3 Correct 0 ms 204 KB Correct! Your size: 5
4 Correct 0 ms 312 KB Correct! Your size: 5
5 Correct 0 ms 204 KB Correct! Your size: 5
6 Correct 0 ms 204 KB Correct! Your size: 5
7 Correct 0 ms 204 KB Correct! Your size: 5
8 Correct 0 ms 204 KB Correct! Your size: 5
9 Correct 0 ms 204 KB Correct! Your size: 5
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Correct! Your size: 49
2 Correct 1 ms 336 KB Correct! Your size: 49
3 Correct 1 ms 208 KB Correct! Your size: 49
4 Correct 1 ms 304 KB Correct! Your size: 49
5 Correct 0 ms 336 KB Correct! Your size: 49
6 Correct 0 ms 208 KB Correct! Your size: 49
7 Correct 0 ms 336 KB Correct! Your size: 49
8 Correct 0 ms 304 KB Correct! Your size: 49