Submission #738337

# Submission time Handle Problem Language Result Execution time Memory
738337 2023-05-08T14:30:41 Z sandry24 Costinland (info1cup19_costinland) C++17
11.9028 / 100
1 ms 212 KB
#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

vi rems;

int get_log(ll k){
    int cnt = 0;
    while(k > 0){
        cnt++;
        rems.pb(k % 6);
        k /= 6;
    }
    return cnt;
}

ll check(vector<vector<char>> &grid, int n, int m){
    ll r[1000][1000], d[1000][1000];
    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];
            }
        }
    }
    ll 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(4) << r[i][j] + d[i][j];
        }
        cout << '\n';
    }
    return ans;
}
 
void solve(){
    int k;
    cin >> k;
    int n = get_log(k) * 2, sz = n+6;
    vector<vector<char>> a(sz, vector<char>(sz, '.'));
    for(int i = 0; i < n-2; i += 2){
        a[i][i] = a[i+1][i] = a[i][i+1] = a[i+1][i+1] = 'X';
        a[i][i+2] = a[i+1][i+2] = 'd';
        a[i+2][i] = a[i+2][i+1] = 'r';
    }
    for(int i = 0; i < rems.size()-1; i++){
        int ind = i*2;
        if(rems[i] == 0)
            continue;
        if(rems[i] == 1){
            a[ind+2][ind] = 'X';
            continue;
        }
        a[ind+2][ind] = 'X';
        a[ind+3][ind] = a[ind+4][ind] = 'd';
        for(int j = 0; j < rems[i]-1; j++){
            a[ind+5+j][ind] = 'X';
            a[ind+5+j][ind+1] = 'd';
        }
    }
    for(int i = 0; i < sz; i++){
        a[sz-1][i] = 'r';
        a[i][sz-1] = 'd';
    }
    a[sz-1][sz-1] = '.';
    for(int i = 0; i < rems.back()-1; i++)
        a[n-2+i][n-2] = 'X';
    cout << sz << ' ' << sz << '\n';
    for(int i = 0; i < sz; i++){
        for(int j = 0; j < sz; j++)
            cout << a[i][j];
        cout << '\n';
    }
    //cout << check(a, sz, sz) << '\n';
}

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 solve()':
costinland.cpp:72:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for(int i = 0; i < rems.size()-1; i++){
      |                    ~~^~~~~~~~~~~~~~~
costinland.cpp: In function 'll check(std::vector<std::vector<char> >&, int, int)':
costinland.cpp:52:38: warning: 'd[<unknown>][<unknown>]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   52 |     ll ans = r[n-1][m-1] + d[n-1][m-1];
      |                            ~~~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 212 KB Partially Correct! Your size: 8
2 Partially correct 0 ms 212 KB Partially Correct! Your size: 8
3 Partially correct 1 ms 212 KB Partially Correct! Your size: 8
4 Partially correct 0 ms 212 KB Partially Correct! Your size: 10
5 Partially correct 0 ms 212 KB Partially Correct! Your size: 10
6 Partially correct 0 ms 212 KB Partially Correct! Your size: 10
7 Partially correct 1 ms 212 KB Partially Correct! Your size: 10
8 Partially correct 1 ms 212 KB Partially Correct! Your size: 10
9 Partially correct 0 ms 212 KB Partially Correct! Your size: 10
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB The matrix does not generate the required number of Costins
2 Halted 0 ms 0 KB -