제출 #255497

#제출 시각아이디문제언어결과실행 시간메모리
255497uacoder123Bitaro’s Party (JOI18_bitaro)C++14
컴파일 에러
0 ms0 KiB
=#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; vi al[100001]; vector<ii> lis[100001]; int vis[100001],vis1[100001],ans[100001]; int r=10,co=0; void dfs(int node) { vis1[node]=1; set<int>se; set<iii> se1; for(int i=0;i<al[node].size();++i) { if(!vis1[al[node][i]]) dfs(al[node][i]); se1.insert(mp(lis[al[node][i]][0].F,mp(al[node][i],0))); } while(se1.size()!=0&&lis[node].size()<r) { auto it=(*(--se1.end())); if(se.find(lis[it.S.F][it.S.S].S)==se.end()) { lis[node].pb(mp(1+it.F,lis[it.S.F][it.S.S].S)); se.insert(lis[it.S.F][it.S.S].S); } se1.erase(it); if(it.S.S==lis[it.S.F].size()-1) se1.insert(mp(lis[it.S.F][it.S.S+1].F,mp(it.S.F,it.S.S+1))); } if(lis[node].size()<r) lis[node].pb(mp(0,node)); } void dfs1(int node) { ans[node]=0; vis1[node]=1; for(int i=0;i<al[node].size();++i) { if(vis1[al[node][i]]==0) { dfs1(al[node][i]); } ans[node]=max(ans[node],1+ans[al[node][i]]); } if(ans[node]==0&&vis[node]==1) ans[node]=-1; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m,q; cin>>n>>m>>q; for(int i=0;i<m;++i) { int f,s; cin>>f>>s; al[s].pb(f); } for(int i=n;i>0;--i) if(vis1[i]==0) dfs(i); vi v; for(int i=0;i<q;++i) { int s,no; cin>>s>>no; int an=-1; for(int j=0;j<no;++j) { int f; cin>>f; vis[f]=1; v.pb(f); } if(no<r) { for(auto j=0;j<lis[s].size();++j) { if(vis[lis[s][j].S]==0) { an=lis[s][j].F; break; } } } else { memset(vis1,0,sizeof(vis1)); dfs1(s); an=ans[s]; } for(int j=0;j<v.size();++j) vis[v[j]]=0; v.clear(); cout<<an<<'\n'; } return 0; }

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

bitaro.cpp:1:2: error: stray '#' in program
 =#include <bits/stdc++.h>
  ^
bitaro.cpp:1:1: error: expected unqualified-id before '=' token
 =#include <bits/stdc++.h>
 ^
bitaro.cpp:14:9: error: 'pair' does not name a type
 typedef pair <lli,lli> ii;
         ^~~~
bitaro.cpp:15:9: error: 'pair' does not name a type
 typedef pair <lli,ii> iii;
         ^~~~
bitaro.cpp:16:9: error: 'vector' does not name a type
 typedef vector <lli> vi;
         ^~~~~~
bitaro.cpp:17:1: error: 'vi' does not name a type
 vi al[100001];
 ^~
bitaro.cpp:18:1: error: 'vector' does not name a type
 vector<ii> lis[100001];
 ^~~~~~
bitaro.cpp: In function 'void dfs(int)':
bitaro.cpp:24:3: error: 'set' was not declared in this scope
   set<int>se;
   ^~~
bitaro.cpp:24:7: error: expected primary-expression before 'int'
   set<int>se;
       ^~~
bitaro.cpp:25:7: error: 'iii' was not declared in this scope
   set<iii> se1;
       ^~~
bitaro.cpp:25:12: error: 'se1' was not declared in this scope
   set<iii> se1;
            ^~~
bitaro.cpp:26:17: error: 'al' was not declared in this scope
   for(int i=0;i<al[node].size();++i)
                 ^~
bitaro.cpp:26:17: note: suggested alternative: 'all'
   for(int i=0;i<al[node].size();++i)
                 ^~
                 all
bitaro.cpp:30:19: error: 'lis' was not declared in this scope
     se1.insert(mp(lis[al[node][i]][0].F,mp(al[node][i],0)));
                   ^
bitaro.cpp:9:27: note: in definition of macro 'mp'
 #define mp(i,a) make_pair(i,a)
                           ^
bitaro.cpp:30:19: note: suggested alternative: 'vis'
     se1.insert(mp(lis[al[node][i]][0].F,mp(al[node][i],0)));
                   ^
bitaro.cpp:9:27: note: in definition of macro 'mp'
 #define mp(i,a) make_pair(i,a)
                           ^
bitaro.cpp:9:17: error: 'make_pair' was not declared in this scope
 #define mp(i,a) make_pair(i,a)
                 ^
bitaro.cpp:30:16: note: in expansion of macro 'mp'
     se1.insert(mp(lis[al[node][i]][0].F,mp(al[node][i],0)));
                ^~
bitaro.cpp:30:41: note: in expansion of macro 'mp'
     se1.insert(mp(lis[al[node][i]][0].F,mp(al[node][i],0)));
                                         ^~
bitaro.cpp:9:17: error: 'make_pair' was not declared in this scope
 #define mp(i,a) make_pair(i,a)
                 ^
bitaro.cpp:30:16: note: in expansion of macro 'mp'
     se1.insert(mp(lis[al[node][i]][0].F,mp(al[node][i],0)));
                ^~
bitaro.cpp:32:24: error: 'lis' was not declared in this scope
   while(se1.size()!=0&&lis[node].size()<r)
                        ^~~
bitaro.cpp:32:24: note: suggested alternative: 'vis'
   while(se1.size()!=0&&lis[node].size()<r)
                        ^~~
                        vis
bitaro.cpp:35:8: error: 'se' was not declared in this scope
     if(se.find(lis[it.S.F][it.S.S].S)==se.end())
        ^~
bitaro.cpp:35:8: note: suggested alternative: 'sz'
     if(se.find(lis[it.S.F][it.S.S].S)==se.end())
        ^~
        sz
bitaro.cpp:9:17: error: 'make_pair' was not declared in this scope
 #define mp(i,a) make_pair(i,a)
                 ^
bitaro.cpp:10:25: note: in definition of macro 'pb'
 #define pb(a) push_back(a)
                         ^
bitaro.cpp:37:20: note: in expansion of macro 'mp'
       lis[node].pb(mp(1+it.F,lis[it.S.F][it.S.S].S));
                    ^~
bitaro.cpp:9:17: error: 'make_pair' was not declared in this scope
 #define mp(i,a) make_pair(i,a)
                 ^
bitaro.cpp:42:18: note: in expansion of macro 'mp'
       se1.insert(mp(lis[it.S.F][it.S.S+1].F,mp(it.S.F,it.S.S+1)));
                  ^~
bitaro.cpp:42:45: note: in expansion of macro 'mp'
       se1.insert(mp(lis[it.S.F][it.S.S+1].F,mp(it.S.F,it.S.S+1)));
                                             ^~
bitaro.cpp:9:17: error: 'make_pair' was not declared in this scope
 #define mp(i,a) make_pair(i,a)
                 ^
bitaro.cpp:42:18: note: in expansion of macro 'mp'
       se1.insert(mp(lis[it.S.F][it.S.S+1].F,mp(it.S.F,it.S.S+1)));
                  ^~
bitaro.cpp:44:8: error: 'lis' was not declared in this scope
     if(lis[node].size()<r)
        ^~~
bitaro.cpp:44:8: note: suggested alternative: 'vis'
     if(lis[node].size()<r)
        ^~~
        vis
bitaro.cpp:9:17: error: 'make_pair' was not declared in this scope
 #define mp(i,a) make_pair(i,a)
                 ^
bitaro.cpp:10:25: note: in definition of macro 'pb'
 #define pb(a) push_back(a)
                         ^
bitaro.cpp:45:20: note: in expansion of macro 'mp'
       lis[node].pb(mp(0,node));
                    ^~
bitaro.cpp: In function 'void dfs1(int)':
bitaro.cpp:51:17: error: 'al' was not declared in this scope
   for(int i=0;i<al[node].size();++i)
                 ^~
bitaro.cpp:51:17: note: suggested alternative: 'all'
   for(int i=0;i<al[node].size();++i)
                 ^~
                 all
bitaro.cpp:57:17: error: 'max' was not declared in this scope
       ans[node]=max(ans[node],1+ans[al[node][i]]);
                 ^~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:64:3: error: 'ios_base' has not been declared
   ios_base::sync_with_stdio(false);
   ^~~~~~~~
bitaro.cpp:65:3: error: 'cin' was not declared in this scope
   cin.tie(NULL);
   ^~~
bitaro.cpp:65:3: note: suggested alternative: 'main'
   cin.tie(NULL);
   ^~~
   main
bitaro.cpp:65:11: error: 'NULL' was not declared in this scope
   cin.tie(NULL);
           ^~~~
bitaro.cpp:72:5: error: 'al' was not declared in this scope
     al[s].pb(f);
     ^~
bitaro.cpp:72:5: note: suggested alternative: 'all'
     al[s].pb(f);
     ^~
     all
bitaro.cpp:77:3: error: 'vi' was not declared in this scope
   vi v;
   ^~
bitaro.cpp:77:3: note: suggested alternative: 'vis'
   vi v;
   ^~
   vis
bitaro.cpp:88:9: error: 'v' was not declared in this scope
         v.pb(f);
         ^
bitaro.cpp:92:22: error: 'lis' was not declared in this scope
       for(auto j=0;j<lis[s].size();++j)
                      ^~~
bitaro.cpp:92:22: note: suggested alternative: 'vis'
       for(auto j=0;j<lis[s].size();++j)
                      ^~~
                      vis
bitaro.cpp:103:7: error: 'memset' was not declared in this scope
       memset(vis1,0,sizeof(vis1));
       ^~~~~~
bitaro.cpp:107:19: error: 'v' was not declared in this scope
     for(int j=0;j<v.size();++j)
                   ^
bitaro.cpp:109:7: error: 'v' was not declared in this scope
       v.clear();
       ^
bitaro.cpp:110:5: error: 'cout' was not declared in this scope
     cout<<an<<'\n';
     ^~~~
bitaro.cpp:110:5: note: suggested alternative: 'co'
     cout<<an<<'\n';
     ^~~~
     co