제출 #1081065

#제출 시각아이디문제언어결과실행 시간메모리
1081065oscar1fText editor (CEOI24_editor)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int TAILLE_MAX=1000*1000+5,DECA=(1<<20),INFINI=(int)1000*1000*1000*1000*1000*1000+5; int nbLig,ligDeb,colDeb,ligFin,colFin,nbCol; set<int> interres; vector<int> listeCol; unordered_map<int,int> corres; int tailleLig[TAILLE_MAX],posCol[TAILLE_MAX]; priority_queue<tuple<int,int,int>> possi; int arbreMin[2*DECA]; int dist[TAILLE_MAX][2]; int calcMin(int deb,int fin) { if (deb==fin) { return arbreMin[deb]; } if (deb%2==1) { return min(arbreMin[deb],calcMin(deb+1,fin)); } if (fin%2==0) { return min(arbreMin[fin],calcMin(deb,fin-1)); } return calcMin(deb/2,fin/2); } int calcDistNorm(int lig1,int col1,int lig2,int col2) { if (lig1>=lig2) { swap(lig1,lig2); swap(col1,col2); } int mini=calcMin(DECA+lig1,DECA+lig2); return lig2-lig1+abs(col1-col2)+2*max((int)0,min(col1,col2)-mini); } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>nbLig>>ligDeb>>colDeb>>ligFin>>colFin; interres.insert(colDeb); interres.insert(colFin); interres.insert(1); for (int i=0;i<2*DECA;i++) { arbreMin[i]=INFINI; } for (int i=1;i<=nbLig;i++) { cin>>tailleLig[i]; interres.insert(tailleLig[i]+1); /*for (int j=1;j<=tailleLig[i];j++) { interres.insert(j); }*/ arbreMin[DECA+i]=tailleLig[i]+1; } for (int i=DECA-1;i>0;i--) { arbreMin[i]=min(arbreMin[2*i],arbreMin[2*i+1]); } for (int i:interres) { corres[i]=listeCol.size(); posCol[listeCol.size()]=i; listeCol.push_back(i); } nbCol=listeCol.size(); int lig,col,distCour; for (int i=1;i<=nbLig;i++) { possi.push(make_tuple(calcDistNorm(ligDeb,colDeb,i,1))); possi.push(make_tuple(calcDistNorm(ligDeb,colDeb,i,tailleLig[i]+1))); } while (!possi.empty()) { distCour=-get<0>(possi.top()); lig=get<1>(possi.top()); col=get<2>(possi.top()); possi.pop(); if (dist[lig][col]==-1) { dist[lig][col]=distCour; //gauche if (col==0 and lig>1) { possi.push(make_tuple(-(distCour+1),lig-1,1)); } possi.push(make_tuple(-(distCour+tailleLig[lig]),lig,0)); //droite if (col==1 and lig<nbLig) { possi.push(make_tuple(-(distCour+1),lig+1,0)); } possi.push(make_tuple(-(distCour+tailleLig[lig]),lig,1)); //haut if (lig>1) { if (col==0) { possi.push(make_tuple(-(distCour+1),lig-1,0)); } else { if (tailleLig[lig]>=tailleLig[lig-1]) { possi.push(make_tuple(-(distCour+1),lig-1,1)); } else { possi.push(make_tuple(-(distCour+tailleLig[lig]-tailleLig[lig-1]),lig-1,1)); } } } //bas if (lig<nbLig) { if (col==0) { possi.push(make_tuple(-(distCour+1),lig+1,0)); } else { if (tailleLig[lig]>=tailleLig[lig+1]) { possi.push(make_tuple(-(distCour+1),lig+1,1)); } else { possi.push(make_tuple(-(distCour+tailleLig[lig]-tailleLig[lig+1]),lig+1,1)); } } } } } int rep=calcDistNorm(ligDeb,colDeb,ligFin,colFin); for (int i=1;i<=nbLig;i++) { rep=min(rep,dist[i][0]+calcDistNorm(i,1,ligFin,colFin)); rep=min(rep,dist[i][1]+calcDistNorm(i,tailleLig[i]+1,ligFin,colFin)); } cout<<rep<<endl; /*for (int i=1;i<=nbLig;i++) { for (int j=0;j<nbCol;j++) { cout<<dist[i][j]<<"\t"; } cout<<endl; } cout<<dist[ligFin][corres[colFin]]<<endl;*/ return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:68:63: error: no matching function for call to 'std::priority_queue<std::tuple<long long int, long long int, long long int> >::push(std::tuple<long long int>)'
   68 |         possi.push(make_tuple(calcDistNorm(ligDeb,colDeb,i,1)));
      |                                                               ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::less<std::tuple<long long int, long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<long long int, long long int, long long int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from 'std::tuple<long long int>' to 'const value_type&' {aka 'const std::tuple<long long int, long long int, long long int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::less<std::tuple<long long int, long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<long long int, long long int, long long int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from 'std::tuple<long long int>' to 'std::priority_queue<std::tuple<long long int, long long int, long long int> >::value_type&&' {aka 'std::tuple<long long int, long long int, long long int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
Main.cpp:69:76: error: no matching function for call to 'std::priority_queue<std::tuple<long long int, long long int, long long int> >::push(std::tuple<long long int>)'
   69 |         possi.push(make_tuple(calcDistNorm(ligDeb,colDeb,i,tailleLig[i]+1)));
      |                                                                            ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::less<std::tuple<long long int, long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<long long int, long long int, long long int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from 'std::tuple<long long int>' to 'const value_type&' {aka 'const std::tuple<long long int, long long int, long long int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::less<std::tuple<long long int, long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<long long int, long long int, long long int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from 'std::tuple<long long int>' to 'std::priority_queue<std::tuple<long long int, long long int, long long int> >::value_type&&' {aka 'std::tuple<long long int, long long int, long long int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~