Submission #28585

#TimeUsernameProblemLanguageResultExecution timeMemory
28585볼빨간 승관이 (#68)Alternative Mart (FXCUP2_mart)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using std::vector; using std::pair; using pii = pair<int, int>; vector<pii> dist[50010]; vector<pii> G[50010]; bool chk[50010]; struct node { int d; int idx; int from; bool operator>(const node& p)const { return d > p.d; } }; pii has(const vector<pii>& vec, int a) { for (auto& b : vec) { if (b.second == a)return b; } return{ -1,-1 }; } int main() { int n, m, k, q; scanf("%d%d%d%d", &n, &m, &k, &q); std::queue<node> que; for (int i = 0; i < k; i++) { int a; scanf("%d", &a); que.push({ 0,a,a }); dist[a].push_back({ 0,a }); } for (int i = 0; i < m; i++) { int a, b, c; scanf("%d%d%d", &a, &b, &c); G[a].push_back({ b,c }); G[b].push_back({ a,c }); } while (!que.empty()) { int idx = que.front().idx; que.pop(); chk[idx] = false; for (pii& p : dist[idx]) { int d = p.first; int from = p.second; for (auto next : G[idx]) { int to = next.first; int cost = next.second; bool has = false; for (pii& a : dist[to]) { if (a.second == from) { has = true; if (a.first > d + cost) { a.first = d + cost; if (!chk[to]) { chk[to] = true; que.push({ d + cost, to }); } } break; } } if (!has) { dist[to].push_back({ d + cost,from }); if (dist[to].size() > 11) { auto it = std::max_element(dist[to].begin(), dist[to].end()); if (it->second != from) { if (!chk[to]) { chk[to] = true; que.push({ d + cost, to }); } } dist[to].erase(it); } else { if (!chk[to]) { chk[to] = true; que.push({ d + cost, to }); } } } } } } while (q--) { int s, x; scanf("%d%d", &s, &x); int arr[10]; for (int i = 0; i < x; i++) { scanf("%d", &arr[i]); chk[arr[i]] = true; } for (pii& p : dist[s]) { if (!chk[p.second]) { printf("%d %d\n", p.second, p.first); break; } } for (int i = 0; i < x; i++) { chk[arr[i]] = false; } } }

Compilation message (stderr)

mart.cpp:5:7: error: expected nested-name-specifier before 'pii'
 using pii = pair<int, int>;
       ^
mart.cpp:6:8: error: 'pii' was not declared in this scope
 vector<pii> dist[50010];
        ^
mart.cpp:6:11: error: template argument 1 is invalid
 vector<pii> dist[50010];
           ^
mart.cpp:6:11: error: template argument 2 is invalid
mart.cpp:7:8: error: 'pii' was not declared in this scope
 vector<pii> G[50010];
        ^
mart.cpp:7:11: error: template argument 1 is invalid
 vector<pii> G[50010];
           ^
mart.cpp:7:11: error: template argument 2 is invalid
mart.cpp:18:1: error: 'pii' does not name a type
 pii has(const vector<pii>& vec, int a) {
 ^
mart.cpp: In function 'int main()':
mart.cpp:31:12: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   que.push({ 0,a,a });
            ^
mart.cpp:31:21: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   que.push({ 0,a,a });
                     ^
mart.cpp:32:11: error: request for member 'push_back' in 'dist[a]', which is of non-class type 'int'
   dist[a].push_back({ 0,a });
           ^
mart.cpp:32:21: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   dist[a].push_back({ 0,a });
                     ^
mart.cpp:37:8: error: request for member 'push_back' in 'G[a]', which is of non-class type 'int'
   G[a].push_back({ b,c });
        ^
mart.cpp:37:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   G[a].push_back({ b,c });
                  ^
mart.cpp:38:8: error: request for member 'push_back' in 'G[b]', which is of non-class type 'int'
   G[b].push_back({ a,c });
        ^
mart.cpp:38:18: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   G[b].push_back({ a,c });
                  ^
mart.cpp:45:8: error: 'pii' was not declared in this scope
   for (pii& p : dist[idx]) {
        ^
mart.cpp:45:15: error: found ':' in nested-name-specifier, expected '::'
   for (pii& p : dist[idx]) {
               ^
mart.cpp:45:13: error: 'p' has not been declared
   for (pii& p : dist[idx]) {
             ^
mart.cpp:89:2: error: expected primary-expression before '}' token
  }
  ^
mart.cpp:89:2: error: expected ';' before '}' token
mart.cpp:89:2: error: expected primary-expression before '}' token
mart.cpp:89:2: error: expected ')' before '}' token
mart.cpp:89:2: error: expected primary-expression before '}' token
mart.cpp:98:8: error: 'pii' was not declared in this scope
   for (pii& p : dist[s]) {
        ^
mart.cpp:98:15: error: found ':' in nested-name-specifier, expected '::'
   for (pii& p : dist[s]) {
               ^
mart.cpp:98:13: error: 'p' has not been declared
   for (pii& p : dist[s]) {
             ^
mart.cpp:104:3: error: expected primary-expression before 'for'
   for (int i = 0; i < x; i++) {
   ^
mart.cpp:104:3: error: expected ';' before 'for'
mart.cpp:104:3: error: expected primary-expression before 'for'
mart.cpp:104:3: error: expected ')' before 'for'
mart.cpp:26: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:30:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a);
                  ^
mart.cpp:36:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &a, &b, &c);
                              ^
mart.cpp:92:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &s, &x);
                        ^
mart.cpp:95:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &arr[i]);
                        ^