Submission #1158145

#TimeUsernameProblemLanguageResultExecution timeMemory
1158145akzytrBitaro’s Party (JOI18_bitaro)C++20
0 / 100
2 ms5696 KiB
#include <bits/stdc++.h> #define ve vector #define ar array #define pb push_back #define ins insert #define endl '\n' #define ll long long using namespace std; const int MXN = 1e5+1; ve<int> adj[MXN]; int blck[MXN]; int from[MXN]; ve<pair<int, int>> madst[MXN+1]; const int BLCK = 100; ll ansgy(ll x, ll i){ priority_queue<pair<int, int>> g; int dst[MXN]; fill(dst, dst+MXN, -1); g.push({0, x}); while(!g.empty()){ auto top = g.top(); g.pop(); if(top.first > dst[top.second]){ dst[top.second] = top.first; for(int i : adj[top.second]){ g.push({1+top.first, i}); } } } int as = -1; for(int j = 0; j < MXN; j++){ if(blck[j] != i){ as = max(as, dst[j]); } } return as; } void populate(ll x){ madst[x].pb({0, x}); ve<int> co; for(int i : adj[x]){ for(auto [dst, y] : madst[i]){ if(from[y] == -1){ co.pb(y); from[y] = dst+1; } else{ from[y] = max(from[y], dst+1); } } } for(int i : co){ madst[x].pb({from[i], i}); from[i] = -1; } sort(madst[x].rbegin(), madst[x].rend()); while(madst[x].size() > BLCK){ madst[x].pop_back(); } } int main(){ fill(blck, blck+MXN, -1); fill(from, from+MXN, -1); int n, m, q; scanf("%d %d %d", &n, &m, &q); for(int i = 0; i < m; i++){ int a, b; scanf("%d %d", &a, &b); adj[b].pb(a); } for(int i = 1; i <= n; i++){ populate(i); } for(int i = 0; i < q; i++){ int t, sz; scanf("%d %d", &t, &sz); int ans = -1; for(int j = 0; j < sz; j++){ int y; scanf("%d", &y); blck[y] = i; } if(sz >= BLCK){ ans = ansgy(t, i); } else{ // cout << t << " : " << endl; for(auto [u,v]: madst[t]){ // cout << v << " " << u << endl; if(blck[v] != i){ ans = max(ans, u); } } } printf("%d\n", &ans); } }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:104:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'int*' [-Wformat=]
  104 |         printf("%d\n", &ans);
      |                 ~^     ~~~~
      |                  |     |
      |                  int   int*
      |                 %n
bitaro.cpp:73:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |     scanf("%d %d %d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:77:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:85:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         scanf("%d %d", &t, &sz);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
bitaro.cpp:89:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |             scanf("%d", &y);
      |             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...