제출 #1361441

#제출 시각아이디문제언어결과실행 시간메모리
1361441yyc000123Monster-Go (EGOI25_monstergo)C++20
98 / 100
1 ms344 KiB
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int N = 55 ;
vector<pair<int,int>> vp[2] = {{{13,13},{7,14},{5,15},{4,16},{3,18},{1,12}},{{28,16},{15,18}}} ;
int dp[N] , n ;
pair<int,int> from[N] ;

void f(int cnt , int k){
    int a = 12/k+2 ;
    for(int i=0 ; i<a ; i++){
        for(int j=i+1 ; j<a ; j++){
            for(int l=0 ; l<a ; l++){
                if(l==i || l==j) continue ;
                for(int m=0 ; m<k ; m++) cout << cnt+l*k+m << ' ' ;
            }
            cout << '\n' ;
        }
    }
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) ;
    memset(dp,0x3f,sizeof(dp)) ;
    dp[0]=0 ;
    for(int i=1 ; i<=50 ; i++){
        for(int j=0 ; j<2 ; j++){
            for(int l=0 ; l<vp[j].size() ; l++){
                if(i-vp[j][l].first>=0){
                    if(dp[i-vp[j][l].first]+vp[j][l].second<dp[i]) from[i]={j,l} ;
                    dp[i]=min(dp[i],dp[i-vp[j][l].first]+vp[j][l].second) ;
                }
            }
        }
    }
    // int tempcnt = 0 ; for(int i=1 ; i<=50 ; i++) if(dp[i]<=50) tempcnt++ ; cout << tempcnt << '\n' ; //
    // for(int i=1 ; i<=50 ; i++) cout << dp[i] << ' ' ; cout << '\n' ; return 0 ; //
    // for(int i=1 ; i<=50 ; i++) cout << from[i] << ' ' ; cout << '\n' ;
    cin >> n ;
    int cnt=0 ;
    while(n){
        int a = vp[from[n].first][from[n].second].first , b = vp[from[n].first][from[n].second].second/vp[from[n].first][from[n].second].first ;
        if(from[n].first==1){
            if(from[n].second==0) f(cnt,2) ;
            else f(cnt,3) ;
            cnt+=vp[from[n].first][from[n].second].second ;
            n-=vp[from[n].first][from[n].second].first ;
            continue ;
        }
        for(int i=0 ; i<a ; i++){
            for(int j=0 ; j<a ; j++){
                if(i==j && a!=1) continue ;
                for(int l=0 ; l<b ; l++) cout << cnt+j*b+l << ' ' ;
            }
            cout << '\n' ;
        }
        cnt+=vp[from[n].first][from[n].second].second ;
        n-=vp[from[n].first][from[n].second].first ;
    }
    return 0 ;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…