제출 #1193674

#제출 시각아이디문제언어결과실행 시간메모리
1193674omarrrrCity Mapping (NOI18_citymapping)C++20
컴파일 에러
0 ms0 KiB
#include "citymapping.h" #include<bits/stdc++.h> #define ll long long #define F first #define S second #define pb push_back using namespace std; bool wchek[1001]; bool vis[1001]; ll link[1001]; struct nd{ ll a,b,w; }; vector<pair<ll,ll>>v; vector<nd>res; void dfs(ll node,ll p){ vis[node]=1; vector<ll>no; if(link[node]>=3) return; for(ll i=0;i<v.size();i++){ if(!vis[v[i].S] && wchek[v[i].S]){ ll d=get_distance(node,v[i].S); if(d<v[i].F){ dfs(v[i].S,node); link[node]++; res.pb({node,v[i].S,d}); }else{ no.pb(v[i].S); wchek[v[i].S]=0; } } if(link[node]>=3) break; } for(ll x:no){ wchek[x]=1; } return; } void find_roads(int n, int Q, int A[], int B[], int W[]) { for(ll i=1;i<=1000;i++){ wchek[i]=true; link[i]=0; } for(ll i=2;i<=n;i++){ ll d=get_distance(1, i); v.pb({d,i}); } sort(v.begin(),v.end()); ll c=0; for(ll i=0;i<n;i++){ if(!vis[v[i].S]){ dfs(v[i].S,1); A[c]=1; B[c]=v[i].S; W[c]=v[i].F; c++; link[1]++; link[v[i].F]++; } if(c>=3) break; } for(ll i=0;i<res.size();i++){ A[c]=res[i].a; B[c]=res[i].b; W[c]=res[i].w; } return; }

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

citymapping.cpp:10:13: error: 'long long int link [1001]' redeclared as different kind of entity
   10 | ll link[1001];
      |             ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/11/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,
                 from citymapping.cpp:2:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
citymapping.cpp: In function 'void dfs(long long int, long long int)':
citymapping.cpp:21:17: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |     if(link[node]>=3)
      |                 ^
citymapping.cpp:21:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   21 |     if(link[node]>=3)
      |        ~~~~~~~~~~^~~
citymapping.cpp:28:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |                link[node]++;
      |                         ^
citymapping.cpp:28:25: warning: ISO C++ forbids incrementing a pointer of type 'int (*)(const char*, const char*) noexcept' [-Wpointer-arith]
   28 |                link[node]++;
      |                ~~~~~~~~~^
citymapping.cpp:28:25: error: lvalue required as increment operand
   28 |                link[node]++;
      |                         ^
citymapping.cpp:35:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   35 |         if(link[node]>=3)
      |                     ^
citymapping.cpp:35:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   35 |         if(link[node]>=3)
      |            ~~~~~~~~~~^~~
citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:48:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   48 |         link[i]=0;
      |               ^
citymapping.cpp:48:16: error: assignment of read-only location '*(link + ((sizetype)i))'
   48 |         link[i]=0;
      |         ~~~~~~~^~
citymapping.cpp:66:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   66 |             link[1]++;
      |                   ^
citymapping.cpp:66:19: warning: ISO C++ forbids incrementing a pointer of type 'int (*)(const char*, const char*) noexcept' [-Wpointer-arith]
   66 |             link[1]++;
      |             ~~~~~~^
citymapping.cpp:66:19: error: lvalue required as increment operand
   66 |             link[1]++;
      |                   ^
citymapping.cpp:67:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   67 |             link[v[i].F]++;
      |                        ^
citymapping.cpp:67:24: warning: ISO C++ forbids incrementing a pointer of type 'int (*)(const char*, const char*) noexcept' [-Wpointer-arith]
   67 |             link[v[i].F]++;
      |             ~~~~~~~~~~~^
citymapping.cpp:67:24: error: lvalue required as increment operand
   67 |             link[v[i].F]++;
      |                        ^