Submission #1092181

#TimeUsernameProblemLanguageResultExecution timeMemory
1092181TgX_2Kronican (COCI16_kronican)C++17
0 / 100
75 ms65536 KiB
/*----------------------------- Author : TgX.2 11Ti - K28 - CHV -----------------------------*/ #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i += 1) #define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i -= 1) #define FORC(i, a, b, c) for (int i = (a), _b = (b), _c = (c); i <= _b; i += _c) #define fi first #define se second #define pb push_back #define len(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() #define _ << " " << #define __ << "\n" #define ___ << " " #define ______________TgX______________ main() #define int long long #define intmax 1e9 #define intmin -1e9 #define llongmax 1e18 #define llongmin -1e18 #define memo(a, val) memset((a), (val), sizeof((a))) using namespace std; #define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout << endl; } void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << "[ " << *it << " = " << a << " ] "; err(++it, args...); } template<typename T1, typename T2> ostream& operator << (ostream& out, const pair<T1, T2>& p) { return out << "[ " << p.first << " , " << p.second << " ] "; } template<class Con, class = decltype(begin(declval<Con>()))> typename enable_if<!is_same<Con, string>::value, ostream&>::type operator << (ostream& out, const Con& con) { out << "{ "; for (auto beg = con.begin(), it = beg; it != con.end(); it++) { out << (it == beg ? "" : ", ") << *it; } return out << " } "; } template <int D, typename T> struct Vec : public vector<Vec<D - 1, T>> { template <typename... Args> Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {} }; template <typename T> struct Vec<1, T> : public vector<T> { Vec(int n = 0, const T &val = T()) : vector<T>(n, val) {} }; template<typename T1, typename T2> bool mini(T1 &a, T2 b) {if (a > b) a = b; else return 0; return 1;} template<typename T1, typename T2> bool maxi(T1 &a, T2 b) {if (a < b) a = b; else return 0; return 1;} /*-----------------------------*/ int n, k, a[25][25]; int f[(1 << 20)][20]; int dp(int mask, int cnt) { if (__builtin_popcount(mask) == n) return (cnt <= k ? 0 : intmax); int &ans = f[mask][cnt]; if (ans != -1) return ans; ans = intmax; FOR(i, 0, n - 1) if ((mask & (1 << i)) == 0) { mini(ans, dp(mask | (1 << i), cnt + 1)); FOR(j, 0, n - 1) if (j != i) mini(ans, dp(mask | (1 << j), cnt) + min(a[i][j], a[j][i])); } return ans; } void process() { cin >> n >> k; FOR(i, 0, n - 1) FOR(j, 0, n - 1) cin >> a[i][j]; memo(f, -1); cout << dp(0, 0); } /*-----------------------------*/ ______________TgX______________ { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("temp.inp", "r")) { freopen("temp.inp", "r", stdin); freopen("temp.out", "w", stdout); } process(); // cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC __ ; } /*==============================+ |INPUT | --------------------------------| ================================+ |OUTPUT | --------------------------------| ===============================*/

Compilation message (stderr)

kronican.cpp:22:41: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | #define ______________TgX______________ main()
      |                                         ^~~~
kronican.cpp:102:1: note: in expansion of macro '______________TgX______________'
  102 | ______________TgX______________ {
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kronican.cpp: In function 'int main()':
kronican.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen("temp.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kronican.cpp:107:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  107 |         freopen("temp.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...