제출 #28681

#제출 시각아이디문제언어결과실행 시간메모리
28681tlwpdus 팬클럽 회장 (#68)Alternative Mart (FXCUP2_mart)C++14
0 / 1
3 ms5736 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; struct Dat{ int s, x, d; bool operator<(const Dat &oth) const { return (d == oth.d) ? (s > oth.s) : (d > oth.d); } }; const int inf = 1e9; int n, m, k, q, chk[50010]; set<pii> md[50010]; vector<pii> e[50010]; priority_queue<Dat> pq; int main(){ scanf("%d%d%d%d", &n, &m, &k, &q); for(int i = 1, x; i <= k; i++){ scanf("%d", &x); md[x].insert(pii(0, x)); pq.push({x, x, 0}); } for(int x, y, c; m--; ){ scanf("%d%d%d", &x, &y, &c); e[x].push_back({y, c}); e[y].push_back({x, c}); } while(!pq.empty()){ Dat c = pq.top(); pq.pop(); for(auto &i : e[c.x]){ int nx, nd; tie(nx, nd) = i; nd += c.d; int fl = 1; for(auto &i : md[nx]){ if(i.second == c.s){ fl = 0; break; } } if(!fl) continue; pii cq = pii(nd, c.s); md[nx].insert(cq); while(md[nx].size() > 11) md[nx].erase(*md[nx].rbegin()); if(nd <= (*md[nx].rbegin()).first) pq.push({c.s, nx, nd}); } } for(int i = 1, x, c; i <= q; i++){ scanf("%d%d", &x, &c); for(int y; c--; ){ scanf("%d", &y); chk[y] = i; } for(auto &j : md[x]){ if(chk[j.second] == i) continue; printf("%d %d\n", j.second, j.first); break; } } }

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

mart.cpp: In function 'int main()':
mart.cpp:19:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &n, &m, &k, &q);
                                   ^
mart.cpp:21:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
                  ^
mart.cpp:26:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &x, &y, &c);
                              ^
mart.cpp:47:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &c);
                        ^
mart.cpp:49:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &y);
                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...