Submission #852701

#TimeUsernameProblemLanguageResultExecution timeMemory
852701alexddRestore Array (RMI19_restore)C++17
Compilation error
0 ms0 KiB
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online.Write your code in this editor and press "Run" button to compile and execute it.*******************************************************************************/#include<bits/stdc++.h>using namespace std;int cnt0[5005];vector<pair<int,int>> con[5005];int n,m;void calc_cnt0(){ deque<int> dq; dq.push_back(0); while(!dq.empty()) { int nod = dq.front(); dq.pop_front(); for(auto x:con[nod]) { int adj = x.first; if(cnt0[adj] < cnt0[nod] + x.second) { if(adj==0) { cout<<-1;exit(0); } cnt0[adj] = cnt0[nod] + x.second; dq.push_back(adj); } } }}signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>m; int l,r,k,val; for(int i=0;i<m;i++) { cin>>l>>r>>k>>val; l++; r++; if(val==0) { con[l-1].push_back({r,k}); } else { con[r].push_back({l-1,1-k}); } } for(int i=1;i<=n;i++) { cnt0[i]=-1; con[i].push_back({i-1,-1}); con[i-1].push_back({i,0}); } calc_cnt0(); for(int i=0;i<=n;i++) { for(auto x:con[i]) { if(cnt0[x.first] < cnt0[i] + x.second) { cout<<-1; return 0; } } } for(int i=1;i<=n;i++) { if(cnt0[i]==cnt0[i-1]) cout<<1<<" "; else cout<<0<<" "; } return 0;}

Compilation message (stderr)

restore.cpp:1:382: warning: extra tokens at end of #include directive
    1 | /******************************************************************************                              Online C++ Compiler.               Code, Compile, Run and Debug C++ program online.Write your code in this editor and press "Run" button to compile and execute it.*******************************************************************************/#include<bits/stdc++.h>using namespace std;int cnt0[5005];vector<pair<int,int>> con[5005];int n,m;void calc_cnt0(){    deque<int> dq;    dq.push_back(0);    while(!dq.empty())    {        int nod = dq.front();        dq.pop_front();        for(auto x:con[nod])        {            int adj = x.first;            if(cnt0[adj] < cnt0[nod] + x.second)            {            if(adj==0)              {                cout<<-1;exit(0);              }                cnt0[adj] = cnt0[nod] + x.second;                dq.push_back(adj);            }        }    }}signed main(){    ios_base::sync_with_stdio(0);cin.tie(0);    cin>>n>>m;    int l,r,k,val;    for(int i=0;i<m;i++)    {        cin>>l>>r>>k>>val;        l++;        r++;        if(val==0)        {            con[l-1].push_back({r,k});        }        else        {            con[r].push_back({l-1,1-k});        }    }    for(int i=1;i<=n;i++)    {        cnt0[i]=-1;        con[i].push_back({i-1,-1});        con[i-1].push_back({i,0});    }    calc_cnt0();    for(int i=0;i<=n;i++)    {        for(auto x:con[i])        {            if(cnt0[x.first] < cnt0[i] + x.second)            {                cout<<-1;                return 0;            }        }    }    for(int i=1;i<=n;i++)    {        if(cnt0[i]==cnt0[i-1])            cout<<1<<" ";        else            cout<<0<<" ";    }    return 0;}
      |                                                                                                                                                                                                                                                                                                                                                                                              ^~~~~~~~~
restore.cpp:1:361: fatal error: bits/stdc++.h>usin: No such file or directory
    1 | /******************************************************************************                              Online C++ Compiler.               Code, Compile, Run and Debug C++ program online.Write your code in this editor and press "Run" button to compile and execute it.*******************************************************************************/#include<bits/stdc++.h>using namespace std;int cnt0[5005];vector<pair<int,int>> con[5005];int n,m;void calc_cnt0(){    deque<int> dq;    dq.push_back(0);    while(!dq.empty())    {        int nod = dq.front();        dq.pop_front();        for(auto x:con[nod])        {            int adj = x.first;            if(cnt0[adj] < cnt0[nod] + x.second)            {            if(adj==0)              {                cout<<-1;exit(0);              }                cnt0[adj] = cnt0[nod] + x.second;                dq.push_back(adj);            }        }    }}signed main(){    ios_base::sync_with_stdio(0);cin.tie(0);    cin>>n>>m;    int l,r,k,val;    for(int i=0;i<m;i++)    {        cin>>l>>r>>k>>val;        l++;        r++;        if(val==0)        {            con[l-1].push_back({r,k});        }        else        {            con[r].push_back({l-1,1-k});        }    }    for(int i=1;i<=n;i++)    {        cnt0[i]=-1;        con[i].push_back({i-1,-1});        con[i-1].push_back({i,0});    }    calc_cnt0();    for(int i=0;i<=n;i++)    {        for(auto x:con[i])        {            if(cnt0[x.first] < cnt0[i] + x.second)            {                cout<<-1;                return 0;            }        }    }    for(int i=1;i<=n;i++)    {        if(cnt0[i]==cnt0[i-1])            cout<<1<<" ";        else            cout<<0<<" ";    }    return 0;}
      |                                                                                                                                                                                                                                                                                                                                                                         ^~~~~~~~~~~~~~~~~~~~
compilation terminated.