답안 #852691

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
852691 2023-09-22T14:07:07 Z alexdd Restore Array (RMI19_restore) C++17
컴파일 오류
0 ms 0 KB
#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

restore.cpp:17:2: error: extended character   is not valid in an identifier
   17 |             if(cnt0[adj] < cnt0[nod] + x.second)
      |  ^
restore.cpp:17:5: error: extended character   is not valid in an identifier
   17 |             if(cnt0[adj] < cnt0[nod] + x.second)
      |    ^
restore.cpp:17:8: error: extended character   is not valid in an identifier
   17 |             if(cnt0[adj] < cnt0[nod] + x.second)
      |      ^
restore.cpp:17:11: error: extended character   is not valid in an identifier
   17 |             if(cnt0[adj] < cnt0[nod] + x.second)
      |        ^
restore.cpp:17:14: error: extended character   is not valid in an identifier
   17 |             if(cnt0[adj] < cnt0[nod] + x.second)
      |          ^
restore.cpp:17:17: error: extended character   is not valid in an identifier
   17 |             if(cnt0[adj] < cnt0[nod] + x.second)
      |            ^
restore.cpp:18:2: error: extended character   is not valid in an identifier
   18 |             {
      |  ^
restore.cpp:18:5: error: extended character   is not valid in an identifier
   18 |             {
      |    ^
restore.cpp:18:8: error: extended character   is not valid in an identifier
   18 |             {
      |      ^
restore.cpp:18:11: error: extended character   is not valid in an identifier
   18 |             {
      |        ^
restore.cpp:18:14: error: extended character   is not valid in an identifier
   18 |             {
      |          ^
restore.cpp:18:17: error: extended character   is not valid in an identifier
   18 |             {
      |            ^
restore.cpp:19:2: error: extended character   is not valid in an identifier
   19 |               if(adj==0)
      |  ^
restore.cpp:19:5: error: extended character   is not valid in an identifier
   19 |               if(adj==0)
      |    ^
restore.cpp:19:8: error: extended character   is not valid in an identifier
   19 |               if(adj==0)
      |      ^
restore.cpp:19:11: error: extended character   is not valid in an identifier
   19 |               if(adj==0)
      |        ^
restore.cpp:19:14: error: extended character   is not valid in an identifier
   19 |               if(adj==0)
      |          ^
restore.cpp:19:17: error: extended character   is not valid in an identifier
   19 |               if(adj==0)
      |            ^
restore.cpp:19:20: error: extended character   is not valid in an identifier
   19 |               if(adj==0)
      |              ^
restore.cpp:20:2: error: extended character   is not valid in an identifier
   20 |                 {
      |  ^
restore.cpp:20:5: error: extended character   is not valid in an identifier
   20 |                 {
      |    ^
restore.cpp:20:8: error: extended character   is not valid in an identifier
   20 |                 {
      |      ^
restore.cpp:20:11: error: extended character   is not valid in an identifier
   20 |                 {
      |        ^
restore.cpp:20:14: error: extended character   is not valid in an identifier
   20 |                 {
      |          ^
restore.cpp:20:17: error: extended character   is not valid in an identifier
   20 |                 {
      |            ^
restore.cpp:20:20: error: extended character   is not valid in an identifier
   20 |                 {
      |              ^
restore.cpp:20:23: error: extended character   is not valid in an identifier
   20 |                 {
      |                ^
restore.cpp:21:2: error: extended character   is not valid in an identifier
   21 |                 cout<
      |  ^
restore.cpp:21:5: error: extended character   is not valid in an identifier
   21 |                 cout<
      |    ^
restore.cpp:21:8: error: extended character   is not valid in an identifier
   21 |                 cout<
      |      ^
restore.cpp:21:11: error: extended character   is not valid in an identifier
   21 |                 cout<
      |        ^
restore.cpp:21:14: error: extended character   is not valid in an identifier
   21 |                 cout<
      |          ^
restore.cpp:21:17: error: extended character   is not valid in an identifier
   21 |                 cout<
      |            ^
restore.cpp:21:20: error: extended character   is not valid in an identifier
   21 |                 cout<
      |              ^
restore.cpp:21:23: error: extended character   is not valid in an identifier
   21 |                 cout<
      |                ^
restore.cpp:22:2: error: extended character   is not valid in an identifier
   22 |             <-1;exit(0);}
      |  ^
restore.cpp:22:5: error: extended character   is not valid in an identifier
   22 |             <-1;exit(0);}
      |    ^
restore.cpp:22:8: error: extended character   is not valid in an identifier
   22 |             <-1;exit(0);}
      |      ^
restore.cpp:22:11: error: extended character   is not valid in an identifier
   22 |             <-1;exit(0);}
      |        ^
restore.cpp:22:14: error: extended character   is not valid in an identifier
   22 |             <-1;exit(0);}
      |          ^
restore.cpp:22:17: error: extended character   is not valid in an identifier
   22 |             <-1;exit(0);}
      |            ^
restore.cpp:23:2: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |  ^
restore.cpp:23:5: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |    ^
restore.cpp:23:8: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |      ^
restore.cpp:23:11: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |        ^
restore.cpp:23:14: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |          ^
restore.cpp:23:17: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |            ^
restore.cpp:23:20: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |              ^
restore.cpp:23:23: error: extended character   is not valid in an identifier
   23 |                 cnt0[adj] = cnt0[nod] + x.second;
      |                ^
restore.cpp: In function 'void calc_cnt0()':
restore.cpp:17:2: error: '\U000000a0' was not declared in this scope
   17 |             if(cnt0[adj] < cnt0[nod] + x.second)
      |  ^
restore.cpp:16:17: warning: unused variable 'adj' [-Wunused-variable]
   16 |             int adj = x.first;
      |                 ^~~
restore.cpp: In function 'int main()':
restore.cpp:73:13: error: expected '}' at end of input
   73 |     return 0;
      |             ^
restore.cpp:30:1: note: to match this '{'
   30 | {
      | ^