Submission #434885

#TimeUsernameProblemLanguageResultExecution timeMemory
434885jeqchoBoxes with souvenirs (IOI15_boxes)C++17
0 / 100
166 ms235168 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second int const N=1e7+3; vector<ll> p; int n,k; bitset<N>vis; vpi adj[N]; ll d[N]; int len[N]; ll delivery(int n1, int K, int L1, int p1[]) { k=K; n=n1; p.rsz(n); ll L=L1; F0R(i,n)p[i]=p1[i]; F0R(i,n) { int w=p[i]*2; adj[0].pb({i+1,w}); } F0R(i,n-1) { int w=p[i+2]-p[i+1]; w*=2; adj[i+1].pb({i+2,w}); adj[i+2].pb({i+1,w}); } priority_queue<pair<int,pii>>q; q.push({0,{0,-1}}); ll ans=0; len[0]=0; while(!q.empty()) { int u,from; ll w=-q.top().fi; tie(u,from)=q.top().se; q.pop(); if(vis[u])continue; vis[u]=1; if(from!=-1)len[u]=len[from]+1; ans += w; if(len[u]==k)continue; trav(e,adj[u]) { if(vis[e.fi])continue; q.push({-e.se,{e.fi,u}}); } } return ans; }

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:40:13: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   40 |   int w=p[i]*2;
boxes.cpp:45:15: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   45 |   int w=p[i+2]-p[i+1];
boxes.cpp:36:5: warning: unused variable 'L' [-Wunused-variable]
   36 |  ll L=L1;
      |     ^
#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...