Submission #180284

# Submission time Handle Problem Language Result Execution time Memory
180284 2020-01-08T15:22:33 Z awlintqaa Kronican (COCI16_kronican) C++14
0 / 100
74 ms 65540 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 500
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;//998244353;
const ll inf=1e18*4;
const ld pai=acos(-1);
ll n,k;
ll a[29][29];
ll dp[(1<<20)+9][21];
ll bt(ll mask,ll crnt){
        if(crnt==k)return 0;
        ll &ret=dp[mask][crnt];
        if(ret!=-1)return ret;
        ret=1e18;
        for(ll i=0;i<n;i++){
                for(ll j=0;j<n;j++){
                        if((mask&(1<<i)) || (mask&(1<<j)))C;
                        ret=min(ret,bt(mask|(1<<i),crnt-(i!=j))+a[i][j]);
                }
        }
        return ret;
}
int main(){
        mem(dp,-1);
        cin>>n>>k;
        for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                        cin>>a[i][j];
        cout<<bt(0,n)<<endl;
}
# Verdict Execution time Memory Grader output
1 Runtime error 74 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 64 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 64 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 72 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 63 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 64 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 63 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 65 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 64 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 63 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)