Submission #431089

#TimeUsernameProblemLanguageResultExecution timeMemory
431089Emin2004Boxes with souvenirs (IOI15_boxes)C++14
0 / 100
2083 ms11340 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define pii pair <int, int> #define pb push_back #define F first #define S second #define ll long long #define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define M_PI 3.14159265358979323846 const int N = 100005; const int mod = 1e9 + 7; vector<ll> a[N]; ll used[N], m, o, z; ll ans = 0, res = LONG_MAX; void DFS(ll node, int rem, int vis){ used[node]--; ll cur = ans; if(vis == z){ ans += min(node, m - node); res = min(res, ans); ans = cur; used[node]++; return; } if(cur > res) { ans = cur; used[node]++; return; } ans += min(node, m - node); if(node != m) DFS(m, o, vis); if(rem == 0) { ans = cur; used[node]++; return; } for(ll i : a[node]){ if(used[i] != 0){ ans = cur + min(abs(node - i), m - abs(node - i)); DFS(i, rem - 1, vis + 1); } } ans = cur; used[node]++; } long long delivery(int n, int k, int l, int p[]) { m = l; o = k; z = n; for(int i = 0; i < n; i++){ a[m].pb(p[i]); used[p[i]]++; for(int j = i + 1; j < n; j++){ int x = p[i]; int y = p[j]; a[x].pb(y); a[y].pb(x); } } DFS(m, k, 0); return res; }

Compilation message (stderr)

boxes.cpp: In function 'void DFS(long long int, int, int)':
boxes.cpp:37:26: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |     if(node != m) DFS(m, o, vis);
      |                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...