이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "bits_stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define all(x) x.begin(), x.end()
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define FOR(i, x, n) for (ll i =x; i<=n; ++i)
#define RFOR(i, x, n) for (ll i =x; i>=n; --i)
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> piii;
ll const INF = 1e13;
ll n, q, l, r, k,v;
vector<pi> adj[5005];
vector<ll> dist1, dist2;
void relax(vector<ll> & dist)
{
for (ll idx=0; idx<=n; ++idx) for (pi u: adj[idx]) dist[u.f] = min(dist[u.f], dist[idx] + u.s);
}
int main()
{
input2(n, q);
for (ll i=0; i<=n; ++i)
{
if (i) adj[i].pb(mp(i-1, 1));
if (i!=n) adj[i].pb(mp(i+1, 0));
}
while (q--)
{
input4(l, r, k, v);
if (v) adj[l].pb(mp(r+1,l-r-2+k));
else adj[r+1].pb(mp(l, r-l+1-k));
}
dist1.assign(n+1, INF);
dist1[0] = 0;
for (ll i=0; i<n; ++i) relax(dist1);
dist2 = dist1;
relax(dist2);
if (dist2!=dist1) {print(-1LL, '\n'); exit(0);}
for (ll i=1; i<=n; ++i) print(dist1[i-1] - dist1[i], ' ');
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
restore.cpp: In function 'int main()':
restore.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | #define input2(x, y) scanf("%lld%lld", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
restore.cpp:49:2: note: in expansion of macro 'input2'
49 | input2(n, q);
| ^~~~~~
restore.cpp:15:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | #define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
restore.cpp:57:3: note: in expansion of macro 'input4'
57 | input4(l, r, k, v);
| ^~~~~~
# | 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... |