제출 #348289

#제출 시각아이디문제언어결과실행 시간메모리
348289tengiz05자리 배치 (IOI18_seats)C++17
컴파일 에러
0 ms0 KiB
#include"seats.h" #include<bits/stdc++.h> using namespace std; vector<pair<int,int>>v; #define pii pair<int,int> int h,w; struct node{ vector<int> mn(20005),mx(20005); int num=10000; void update(int pos,int val){ pos+=num; for(mn[pos]=val,mx[pos]=val;pos>1;pos>>=1){ mn[pos>>1]=min(mn[pos],mn[pos^1]); mx[pos>>1]=max(mx[pos],mx[pos^1]); } } int getmn(int l, int r){ int res=2e9; for(l+=num,r+=num;l<=r;l>>=1,r>>=1){ if(l&1)res=min(res,mn[l++]); if(!(l&1))res=min(res,mn[r--]); } } int getmx(int l, int r){ int res=0; for(l+=num,r+=num;l<=r;l>>=1,r>>=1){ if(l&1)res=max(res,mn[l++]); if(!(l&1))res=max(res,mn[r--]); } } pii get(int l,int r){ pii res={getmn(l,r),getmx(l,r)}; return res; } void build(){ //nothing } }tree1,tree2; void give_initial_chart(int H,int W,vector<int>x,vector<int>y){ tree1.build(); tree2.build(); h=H,w=W; for(int i=0;i<h*w;i++){ v.push_back({x[i],y[i]}); tree1.update(i,x[i]); tree2.update(i,y[i]); } } int swap_seats(int a,int b){ tree1.update(a,v[b].first); tree2.update(a,v[b].second); tree1.update(b,v[a].first); tree2.update(b,v[a].second); swap(v[a],v[b]); int ans=0; for(int i=0;i<h*w;i++){ auto tmp=tree1.get(0,i); int l=tmp.first; int r=tmp.second; tmp=tree2.get(0,i); int u=tmp.first; int d=tmp.second; if((r-l+1)*(d-u+1)==i+1)ans++; else i=max(i,(r-l+1)*(d-u+1)-2); } return ans; }

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

seats.cpp:8:18: error: expected identifier before numeric constant
    8 |   vector<int> mn(20005),mx(20005);
      |                  ^~~~~
seats.cpp:8:18: error: expected ',' or '...' before numeric constant
seats.cpp:8:28: error: expected identifier before numeric constant
    8 |   vector<int> mn(20005),mx(20005);
      |                            ^~~~~
seats.cpp:8:28: error: expected ',' or '...' before numeric constant
seats.cpp: In member function 'void node::update(int, int)':
seats.cpp:12:15: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   12 |     for(mn[pos]=val,mx[pos]=val;pos>1;pos>>=1){
      |               ^
seats.cpp:12:27: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   12 |     for(mn[pos]=val,mx[pos]=val;pos>1;pos>>=1){
      |                           ^
seats.cpp:13:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   13 |       mn[pos>>1]=min(mn[pos],mn[pos^1]);
      |                ^
seats.cpp:13:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   13 |       mn[pos>>1]=min(mn[pos],mn[pos^1]);
      |                            ^
seats.cpp:13:38: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   13 |       mn[pos>>1]=min(mn[pos],mn[pos^1]);
      |                                      ^
seats.cpp:14:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   14 |       mx[pos>>1]=max(mx[pos],mx[pos^1]);
      |                ^
seats.cpp:14:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   14 |       mx[pos>>1]=max(mx[pos],mx[pos^1]);
      |                            ^
seats.cpp:14:38: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   14 |       mx[pos>>1]=max(mx[pos],mx[pos^1]);
      |                                      ^
seats.cpp: In member function 'int node::getmn(int, int)':
seats.cpp:20:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   20 |       if(l&1)res=min(res,mn[l++]);
      |                                ^
seats.cpp:21:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   21 |       if(!(l&1))res=min(res,mn[r--]);
      |                                   ^
seats.cpp:23:3: warning: no return statement in function returning non-void [-Wreturn-type]
   23 |   }
      |   ^
seats.cpp: In member function 'int node::getmx(int, int)':
seats.cpp:27:32: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   27 |       if(l&1)res=max(res,mn[l++]);
      |                                ^
seats.cpp:28:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   28 |       if(!(l&1))res=max(res,mn[r--]);
      |                                   ^
seats.cpp:30:3: warning: no return statement in function returning non-void [-Wreturn-type]
   30 |   }
      |   ^