Submission #521162

#TimeUsernameProblemLanguageResultExecution timeMemory
521162CyberSleeperBitaro’s Party (JOI18_bitaro)C++14
0 / 100
3 ms5324 KiB
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define debug(x) cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl #define all(x) x.begin(), x.end() #define fi first #define se second #define mp make_pair #define pb push_back #define ll long long #define vll vector<ll> #define ull unsigned long long #define pll pair<ll, ll> #define pii pair<int, int> #define ld long double #define nl '\n' #define tb '\t' #define sp ' ' using namespace std; const int MX=100005, MOD=998244353, BLOCK=327, INF=2e9+7; const ll INFF=1e18+7; const ld ERR=1e-7, pi=3.14159265358979323846; int N, M, Q, vis[MX], cnt, DP[MX]; vector<int> adj[MX], C; vector<pii> far[MX]; void comb(int x, int y){ cnt++; vector<pii> ret; int lex=0, ley=0; while(ret.size()<BLOCK && lex<far[x].size() && ley<far[y].size()){ pii le=far[x][lex], ri=far[y][ley]; le.fi++; if(le >= ri){ ret.pb(le); vis[le.se]=cnt; lex++; }else{ ret.pb(ri); vis[ri.se]=cnt; ley++; } while(lex<far[x].size() && vis[far[x][lex].se] == cnt) lex++; while(ley<far[y].size() && vis[far[y][ley].se] == cnt) ley++; } while(ret.size()<BLOCK && lex<far[x].size()){ if(vis[far[x][lex].se] != cnt){ ret.pb(far[x][lex]); ret.back().fi++; } lex++; } while(ret.size()<BLOCK && ley<far[y].size()){ if(vis[far[y][ley].se] != cnt) ret.pb(far[y][ley]); ley++; } far[y]=ret; } int main() { fastio; cin >> N >> M >> Q; for(int i=0, u, v; i<M; i++){ cin >> u >> v; adj[v].pb(u); } for(int i=1; i<=N; i++){ far[i].pb({0, i}); for(auto j:adj[i]){ comb(j, i); } } memset(vis, -1, sizeof(vis)); while(Q--){ int X, Y; cin >> X >> Y; for(int i=Y, x; i>0; i--){ cin >> x; if(x>X){ Y--; }else{ vis[x]=Q; } } if(Y==X){ cout << "-1\n"; continue; } if(Y<BLOCK){ for(auto i:far[X]){ if(vis[i.se] != Q){ cout << i.fi << nl; break; } } cout << "-1\n"; }else{ for(int i=1; i<=X; i++){ DP[i]=(vis[i]==Q ? -INF : 0); for(auto j:adj[i]){ DP[i]=max(DP[j]+1, DP[i]); } } if(DP[X]<0) DP[X]=-1; cout << DP[X] << nl; } } }

Compilation message (stderr)

bitaro.cpp: In function 'void comb(int, int)':
bitaro.cpp:32:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     while(ret.size()<BLOCK && lex<far[x].size() && ley<far[y].size()){
      |                               ~~~^~~~~~~~~~~~~~
bitaro.cpp:32:55: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     while(ret.size()<BLOCK && lex<far[x].size() && ley<far[y].size()){
      |                                                    ~~~^~~~~~~~~~~~~~
bitaro.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         while(lex<far[x].size() && vis[far[x][lex].se] == cnt)
      |               ~~~^~~~~~~~~~~~~~
bitaro.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         while(ley<far[y].size() && vis[far[y][ley].se] == cnt)
      |               ~~~^~~~~~~~~~~~~~
bitaro.cpp:49:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     while(ret.size()<BLOCK && lex<far[x].size()){
      |                               ~~~^~~~~~~~~~~~~~
bitaro.cpp:56:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     while(ret.size()<BLOCK && ley<far[y].size()){
      |                               ~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...