Submission #984359

#TimeUsernameProblemLanguageResultExecution timeMemory
984359saayan007Bridges (APIO19_bridges)C++17
0 / 100
94 ms1012 KiB
#include "bits/stdc++.h" using namespace std; #define int long long #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i) #define repd(i, a, b) for(int (i) = (a); i >= (b); --i) #define em emplace #define eb emplace_back #define pi pair<int, int> #define fr first #define sc second #define mp make_pair const char nl = '\n'; const int mod = 1e9 + 7; const int inf = 1e17; #warning constants according to subtask const int N = 1001; int n, m, q; int ed[N][3]; set<pair<int, int>> adj[N]; int res = 0; bool vis[N]; void modify(int b, int r) { rep(j, 0, 1) adj[ed[b][j]].erase(mp(ed[b][1 - j], ed[b][2])); ed[b][2] = r; rep(j, 0, 1) adj[ed[b][j]].insert(mp(ed[b][1 - j], ed[b][2])); } void dfs(int x, int p, int w) { ++res; vis[x] = 1; for(auto [y, d] : adj[x]) { if(vis[y] || y == p || w > d) continue; dfs(y, x, w); } } void query(int s, int w) { rep(i, 1, n) vis[i] = 0; res = 0; dfs(s, -1, w); cout << res << nl; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; rep(i, 1, m) { rep(j, 0, 2) cin >> ed[i][j]; rep(j, 0, 1) adj[ed[i][j]].insert(mp(ed[i][1 - j], ed[i][2])); } cin >> q; rep(i, 1, q) { int t; cin >> t; if(t == 1) { int b, r; cin >> b >> r; modify(b, r); } else { int s, w; cin >> s >> w; query(s, w); } } }

Compilation message (stderr)

bridges.cpp:20:2: warning: #warning constants according to subtask [-Wcpp]
   20 | #warning constants according to subtask
      |  ^~~~~~~
bridges.cpp: In function 'void modify(long long int, long long int)':
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:29:5: note: in expansion of macro 'rep'
   29 |     rep(j, 0, 1) adj[ed[b][j]].erase(mp(ed[b][1 - j], ed[b][2]));
      |     ^~~
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:31:5: note: in expansion of macro 'rep'
   31 |     rep(j, 0, 1) adj[ed[b][j]].insert(mp(ed[b][1 - j], ed[b][2]));
      |     ^~~
bridges.cpp: In function 'void query(long long int, long long int)':
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:44:5: note: in expansion of macro 'rep'
   44 |     rep(i, 1, n) vis[i] = 0;
      |     ^~~
bridges.cpp: In function 'int32_t main()':
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:55:5: note: in expansion of macro 'rep'
   55 |     rep(i, 1, m) {
      |     ^~~
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:56:9: note: in expansion of macro 'rep'
   56 |         rep(j, 0, 2) cin >> ed[i][j];
      |         ^~~
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:57:9: note: in expansion of macro 'rep'
   57 |         rep(j, 0, 1) adj[ed[i][j]].insert(mp(ed[i][1 - j], ed[i][2]));
      |         ^~~
bridges.cpp:5:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    5 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
bridges.cpp:61:5: note: in expansion of macro 'rep'
   61 |     rep(i, 1, q) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...