실수한점
bool operator<
함수에서 아무것도 반환해 주지 않아서, ,, 실수함
다중조건일때만 if문으로,
bool operator<(Node v, Node t) {
if (t.price > v.price) return 1;
if (t.price < v.price) return 0;
}
둘다 아무조건도 안되는경우를 반환해 주지않아서 에러,,
#include <iostream>
#include <queue>
#include <string>
using namespace std;
string str = "ABCDEFGHIJ";
struct Node {
int price;
string now;
string next;
};
bool operator<(Node v, Node t) {
return t.price > v.price;
}
priority_queue<Node>pq;
int main() {
int n;
int map[10][10];
cin >> n;
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) {
cin >> map[y][x];
}
}
for (int y = 0; y < n; y++) {
for (int x = 0; x < n; x++) {
if (map[y][x] == 0)continue;
Node ret;
ret.price = map[y][x];
ret.now = str[y];
ret.next = str[x];
pq.push(ret);
}
}
for (int i = 0; i < 3; i++) {
cout << pq.top().now << "-" << pq.top().next << " " << pq.top().price << "\n";
pq.pop();
}
return 0;
}