답안 #476940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
476940 2021-09-29T08:49:19 Z leaked Costinland (info1cup19_costinland) C++14
20 / 100
106 ms 204 KB
#include <bits/stdc++.h>
//#include "grader.h"
//#include "grader.cpp"

#define f first
#define s second
#define pb push_back
#define vec vector
#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef pair<int,int> pii;
typedef long double ld;
auto rng=bind(uniform_int_distribution<int>(1,1e9),mt19937(time(0)));
typedef long long ll;
const ll inf=1e18+100;
//const int N=49;
int get(vec<string> s,bool dbg=0){
    int n=sz(s),m=sz(s[0]);
    vec<vec<vec<ll>>>dp(n,vec<vec<ll>>(m,vec<ll>(2,0)));
    if(s[0][0]=='r' || s[0][0]=='X')dp[0][0][0]=1;
    if(s[0][0]=='d' || s[0][0]=='X')dp[0][0][1]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(i==0 && j==0) continue;
//            if(dbg && j==2){
//                debug()<<
//            }
            dp[i][j][0]=(i&&s[i-1][j]!='r'?dp[i-1][j][0]:0);
            dp[i][j][1]=(j&&s[i][j-1]!='d'?dp[i][j-1][1]:0);
            ll sm=dp[i][j][0]+dp[i][j][1];
            if(s[i][j]=='X'){
                dp[i][j][0]=sm;
                dp[i][j][1]=sm;
            }
            else if(s[i][j]=='d') dp[i][j][0]=sm;
            else if(s[i][j]=='r') dp[i][j][1]=sm;
//            if(dbg)debug()<<imie(i)imie(j)imie(dp[i][j][0])imie(dp[i][j][1]);
        }

    }
    return dp[n-1][m-1][0]+dp[n-1][m-1][1];
}
signed main(){
    ///let me bruteforce
    vec<string>s(5,string(5,'.'));
    for(int i=0;i<5;i++){
        s[4][i]='r';
    }
    for(int i=0;i<5;i++) s[i][4]='d';
    s[4][4]='.';
//    debug()<<imie(s);
    ll k;
    cin>>k;
    cout<<5<<' '<<5<<endl;
    for(int mask=0;mask<(1<<(4*4));mask++){
        vec<string>me=s;
        for(int i=0;i<4*4;i++){
            if((1<<i)&mask){
                me[i/4][i%4]='X';
            }
        }
        ll how=get(me);
//        if(mask==1){
////            cout<<get(me,1);
//        }
        if(how==k && me[0][0]!='.'){
            for(int i=0;i<5;i++) cout<<me[i]<<endl;
//            cout<<get(me,1);
            return 0;
        }
//        debug()<<imie(how);
//        for(int i=0;i<4;i++) debug()<<imie(me[i]);
//        debug()<<imie(me)imie(how);
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Correct! Your size: 5
2 Correct 0 ms 204 KB Correct! Your size: 5
3 Correct 1 ms 204 KB Correct! Your size: 5
4 Correct 1 ms 204 KB Correct! Your size: 5
5 Correct 1 ms 204 KB Correct! Your size: 5
6 Correct 1 ms 204 KB Correct! Your size: 5
7 Correct 1 ms 204 KB Correct! Your size: 5
8 Correct 1 ms 204 KB Correct! Your size: 5
9 Correct 2 ms 204 KB Correct! Your size: 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 204 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -