QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#118640#4303. New Levelzym417Compile Error//C++141.7kb2023-07-03 19:53:502023-07-03 19:53:52

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-03 19:53:52]
  • 评测
  • [2023-07-03 19:53:50]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

inline int read() {
    int res = 0, f = 1; char ch;
    while((ch = getchar()) && (ch < '0' || ch > '9') && ch != '-');
    (ch == '-') ? f = -1 : res = ch - '0';
    while((ch = getchar()) && ch >= '0' && ch <= '9') res = (res << 3) + (res << 1) + ch - '0';
    return res * f;
}

inline void print(int x, char ch = '\n') {
    if(x < 0) putchar('-'), x = -x;
    static short prnum[21];
    short prcnt = 0;
    do { prnum[++prcnt] = x % 10; x /= 10; } while(x > 0);
    while(prcnt) putchar(prnum[prcnt--] + '0');
    putchar(ch);
}

const int MAXN = 5e5 + 5, INF = 1e18;

int n, m, K, dis[MAXN];
int tot, hd[MAXN], to[MAXN << 1], nt[MAXN << 1], w[MAXN << 1];
bool vis[MAXN];

inline void add(int x, int y, int z) {
    to[++tot] = y, nt[tot] = hd[x], hd[x] = tot, w[tot] = z;
    to[++tot] = x, nt[tot] = hd[y], hd[y] = tot, w[tot] = z;
}

struct node {
    int w, id;
    bool operator < (const node &x) const { return w > x.w; }
}; priority_queue<node> q;

signed main() {
    n = read(); m = read(); K = read();
    for(int i = 1, x, y; i <= m; i++) {
        x = read(); y = read();
        add(x, y, (a[x] - a[y] - 1 + K) % K);
    }
    for(int i = 1; i <= n; i++) dis[i] = INF;
    q.push(1); dis[1] = 0;
    while(q.size()) {
        int x = q.top().id; q.pop();
        if(vis[x]) continue; vis[x] = true;
        for(int i = hd[x]; i; i = nt[i])
         if(dis[to[i]] > dis[x] + w[i]) {
            dis[to[i]] = dis[x] + w[i];
            q.push({dis[to[i]], to[i]});
         }
    }
    for(int i = 1; i <= n; i++) print(((INF - dis[i]) % K + K) % K, ' ');
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:42:20: error: ‘a’ was not declared in this scope
   42 |         add(x, y, (a[x] - a[y] - 1 + K) % K);
      |                    ^
answer.code:45:11: error: no matching function for call to ‘std::priority_queue<node>::push(int)’
   45 |     q.push(1); dis[1] = 0;
      |     ~~~~~~^~~
In file included from /usr/include/c++/11/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:86,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_queue.h:640:7: note: candidate: ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = node; _Sequence = std::vector<node, std::allocator<node> >; _Compare = std::less<node>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = node]’
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from ‘int’ to ‘const value_type&’ {aka ‘const node&’}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/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 = node; _Sequence = std::vector<node, std::allocator<node> >; _Compare = std::less<node>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = node]’
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from ‘int’ to ‘std::priority_queue<node>::value_type&&’ {aka ‘node&&’}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~