이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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+1]-p[i];
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;
}
컴파일 시 표준 에러 (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+1]-p[i];
boxes.cpp:36:5: warning: unused variable 'L' [-Wunused-variable]
36 | ll L=L1;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |