私はプライオリティキューを使用してアルゴリズムを実装しました。 ここに私のコードははなぜプライオリティキューを使用している間、私は「(」トークンの前に欠落しているテンプレート引数を取得するのですか?
ある#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int first[2]={2,-2};
int second[2]={1,-1};
vector<pair<pair<int,int>,int>>vec;
class compare{
public:
bool operator()(pair<pair<int,int>,int>a,pair<pair<int,int>,int>b)
{
return a.second>b.second;
}
};
int main() {
long long int a,b,c,d;
while(cin>>a>>b>>c>>d)
{
priority_queue(pair<pair<int,int>,int>,vector<pair<pair<int,int>,int>>,compare) q;
map<pair<int,int>,bool>visited;
map<pair<int,int>,int>dist;
map<pair<int,int>,pair<int,int>> parent;
for(int i=1;i<=9;i++)
for(int j=1;j<=9;j++)
{
dist[make_pair(i,j)]=INT_MAX;
visited[make_pair(i,j)]=false;
}
dist[make_pair(a,b)] = 0;
visited[make_pair(a,b)] = true;
q.push(make_pair(make_pair(a,b),0));
while(!q.empty())
{
pair<int,int> node = q.top().first;
int distance = q.top().second;
q.pop();
//followed by relaxation step
}
}
// your code goes here
return 0;
}
問題は、私は次のエラーを取得していますです:
rog.cpp: In function ‘int main()’:
prog.cpp:39:17: error: missing template arguments before ‘(’ token
priority_queue(pair<pair<int,int>,int>,vector<pair<pair<int,int>,int>>,compare) q;
^
prog.cpp:39:41: error: expected primary-expression before ‘,’ token
priority_queue(pair<pair<int,int>,int>,vector<pair<pair<int,int>,int>>,compare) q;
^
prog.cpp:39:73: error: expected primary-expression before ‘,’ token
priority_queue(pair<pair<int,int>,int>,vector<pair<pair<int,int>,int>>,compare) q;
^
prog.cpp:39:73: error: expected primary-expression before ‘)’ token
priority_queue(pair<pair<int,int>,int>,vector<pair<pair<int,int>,int>>,compare) q;
私は正確に誰かが私のためにそれを明確にすることができれば大きな助けになるerror.Itのウォールドの意味が何であるかを理解することはできませんよ
わかりやすくするために、そこに「typedef」または2文字を入れてください。 – Bathsheba
コードに[bits/stdC++。h](https://stackoverflow.com/q/31816095/1782465)を含めるべきではありません。 – Angew
受け入れられた回答に印を付けることを検討してください。ありがとう。 – alhadhrami