#include <bits/stdc++.h>
//#include "grader.h"
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
/*int n = 5, m = 5, K, r[5][5], d[5][5];
void all(int k, int h, vector<vector<char>> &grid){
if(k == n){
k = 0;
h++;
}
if(h == m){
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
r[i][j] = d[i][j] = 0;
}
}
r[0][0] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(i == n-1 && j == m-1)
continue;
if(grid[i][j] == '.'){
r[i][j+1] += r[i][j];
d[i+1][j] += d[i][j];
} else if(grid[i][j] == 'X'){
r[i][j+1] += r[i][j] + d[i][j];
d[i+1][j] += r[i][j] + d[i][j];
} else if(grid[i][j] == 'r'){
r[i][j+1] += r[i][j] + d[i][j];
} else {
d[i+1][j] += r[i][j] + d[i][j];
}
}
}
int ans = r[n-1][m-1] + d[n-1][m-1];
if(ans > 0){
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++)
cout << grid[i][j] << ' ';
cout << '\n';
}
cout << ans << '\n';
}
} else {
if(k == 0 && h == 0){
grid[k][h] = 'd';
all(k+1, h, grid);
grid[k][h] = 'r';
all(k+1, h, grid);
grid[k][h] = 'X';
all(k+1, h, grid);
}
else if(k == n-1 && h == m-1){
grid[k][h] = '.';
all(k+1, h, grid);
} else if(k == n-1){
grid[k][h] = 'd';
all(k+1, h, grid);
} else if(h == m-1){
grid[k][h] = 'r';
all(k+1, h, grid);
} else {
grid[k][h] = '.';
all(k+1, h, grid);
grid[k][h] = 'd';
all(k+1, h, grid);
grid[k][h] = 'r';
all(k+1, h, grid);
grid[k][h] = 'X';
all(k+1, h, grid);
}
}
}*/
int check(vector<vector<char>> &grid){
int r[5][5], d[5][5];
int n = 5, m = 5;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
r[i][j] = d[i][j] = 0;
}
}
r[0][0] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(i == n-1 && j == m-1)
continue;
if(grid[i][j] == '.'){
r[i][j+1] += r[i][j];
d[i+1][j] += d[i][j];
} else if(grid[i][j] == 'X'){
r[i][j+1] += r[i][j] + d[i][j];
d[i+1][j] += r[i][j] + d[i][j];
} else if(grid[i][j] == 'r'){
r[i][j+1] += r[i][j] + d[i][j];
} else {
d[i+1][j] += r[i][j] + d[i][j];
}
}
}
int ans = r[n-1][m-1] + d[n-1][m-1];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << setw(8) << r[i][j] << ' ' << d[i][j];
}
cout << '\n';
}
return ans;
}
void print(vector<vector<char>> &a){
cout << a.size() << ' ' << a[0].size() << '\n';
for(int i = 0; i < a.size(); i++){
for(auto j : a[i])
cout << j;
cout << '\n';
}
}
void solve(){
int k;
cin >> k;
vector<vector<char>> grid(5, vector<char>(5));
int total = 1;
grid[4][4] = '.';
for(int i = 0; i < 4; i++){
grid[4][i] = 'r';
grid[i][4] = 'd';
}
int add = 1;
for(int i = 0; i < 4; i++){
for(int j = 0; j < 4; j++){
if(i == 0){
if(total < k){
grid[i][j] = 'X';
total++;
}
else
grid[i][j] = 'r';
}
if(i == 1){
if(total + add < k){
grid[i][j] = 'X';
total += add;
add++;
} else
grid[i][j] = 'r';
}
if(i == 2){
if(j == 0)
grid[i][j] = 'd';
else
grid[i][j] = 'r';
}
if(i == 3){
if(total < k){
grid[i][j] = 'X';
total++;
}
else
grid[i][j] = 'r';
}
}
}
//cout << check(grid) << '\n';
print(grid);
}
int main(){
//freopen("input.txt", "r", stdin);
//freopen("test.out", "w", stdout);
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
Compilation message
costinland.cpp: In function 'void print(std::vector<std::vector<char> >&)':
costinland.cpp:124:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
124 | for(int i = 0; i < a.size(); i++){
| ~~^~~~~~~~~~
costinland.cpp: In function 'int check(std::vector<std::vector<char> >&)':
costinland.cpp:106:27: warning: array subscript 5 is above array bounds of 'int [5]' [-Warray-bounds]
106 | r[i][j+1] += r[i][j] + d[i][j];
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
costinland.cpp:106:27: warning: array subscript 5 is above array bounds of 'int [5]' [-Warray-bounds]
costinland.cpp:103:27: warning: array subscript 5 is above array bounds of 'int [5]' [-Warray-bounds]
103 | r[i][j+1] += r[i][j] + d[i][j];
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
costinland.cpp:103:27: warning: array subscript 5 is above array bounds of 'int [5]' [-Warray-bounds]
costinland.cpp:100:27: warning: array subscript 5 is above array bounds of 'int [5]' [-Warray-bounds]
100 | r[i][j+1] += r[i][j];
| ~~~~~~~~~~^~~~~~~~~~
costinland.cpp:100:27: warning: array subscript 5 is above array bounds of 'int [5]' [-Warray-bounds]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Correct! Your size: 5 |
2 |
Correct |
0 ms |
212 KB |
Correct! Your size: 5 |
3 |
Correct |
0 ms |
212 KB |
Correct! Your size: 5 |
4 |
Incorrect |
0 ms |
212 KB |
The matrix does not generate the required number of Costins |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
The matrix does not generate the required number of Costins |
2 |
Halted |
0 ms |
0 KB |
- |