제출 #531635

#제출 시각아이디문제언어결과실행 시간메모리
531635i_am_noobRestore Array (RMI19_restore)C++17
7 / 100
620 ms1232 KiB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")

#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define chkmin(a,b) (a=min(a,b))
#define chkmax(a,b) (a=max(a,b))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 777771449
#endif

const int mod=1000000007;
const int maxn=5005,maxm=5,maxk=7777714;

//i_am_noob
int n,m,dis[maxn];
vector<vector<pii>> adj(maxn);

void orzck(){
    cin >> n >> m;
    rep(n) adj[i].pb({i+1,1}),adj[i+1].pb({i,0});
    rep(n+1) adj[n+1].pb({i,0});
    rep(n+2) dis[i]=inf;
    rep(m){
        int l,r,k,x;
        cin >> l >> r >> k >> x;
        if(x==0){
            adj[l].pb({r+1,r+1-l-k});
            bug(l,r+1,r+1-l-k);
        }
        else{
            adj[r+1].pb({l,-(r-l+2-k)});
            bug(r+1,l,-(r-l+2-k));
        }
    }
    dis[n+1]=0;
    rep1(_,n+1){
        rep(n+2) for(auto [v,w]: adj[i]) chkmin(dis[v],dis[i]+w);
        rep(n+2) bug(i,dis[i]);
    }
    rep(n+2) for(auto [v,w]: adj[i]) if(dis[v]>dis[i]+w){
        cout << "-1\n";
        return;
    }
    rep(n) cout << dis[i+1]-dis[i] << ' ';
    cout << "\n";
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    orzck();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

restore.cpp: In function 'void orzck()':
restore.cpp:31:18: warning: statement has no effect [-Wunused-value]
   31 | #define bug(...) 777771449
      |                  ^~~~~~~~~
restore.cpp:51:13: note: in expansion of macro 'bug'
   51 |             bug(l,r+1,r+1-l-k);
      |             ^~~
restore.cpp:31:18: warning: statement has no effect [-Wunused-value]
   31 | #define bug(...) 777771449
      |                  ^~~~~~~~~
restore.cpp:55:13: note: in expansion of macro 'bug'
   55 |             bug(r+1,l,-(r-l+2-k));
      |             ^~~
restore.cpp:31:18: warning: statement has no effect [-Wunused-value]
   31 | #define bug(...) 777771449
      |                  ^~~~~~~~~
restore.cpp:61:18: note: in expansion of macro 'bug'
   61 |         rep(n+2) bug(i,dis[i]);
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...