제출 #370055

#제출 시각아이디문제언어결과실행 시간메모리
370055farhan132Bitaro’s Party (JOI18_bitaro)C++17
100 / 100
1834 ms415300 KiB
/***Farhan132***/ #include <bits/stdc++.h> using namespace std; typedef int ll; typedef unsigned long long ull; typedef double dd; typedef vector<ll> vll; typedef pair<ll , ll> ii; typedef vector< ii > vii; typedef pair < ll , pair < ll , ll > > cm; #define ff first #define ss second #define pb push_back #define in insert #define f0(b) for(int i=0;i<(b);i++) #define f00(b) for(int j=0;j<(b);j++) #define f1(b) for(int i=1;i<=(b);i++) #define f11(b) for(int j=1;j<=(b);j++) #define f2(a,b) for(int i=(a);i<=(b);i++) #define f22(a,b) for(int j=(a);j<=(b);j++) #define sf(a) scanf("%lld",&a) #define sff(a,b) scanf("%lld %lld", &a , &b) #define pf(a) printf("%lld\n",a) #define pff(a,b) printf("%lld %lld\n", a , b) #define PI 3.14159265359 #define bug printf("**!\n") #define mem(a , b) memset(a, b ,sizeof(a)) #define front_zero(n) __builtin_clzll(n) #define back_zero(n) __builtin_ctzll(n) #define total_one(n) __builtin_popcountll(n) #define clean fflush(stdout) const ll mod = (ll)1e9 + 7; const ll maxn = (ll)1e5 + 5; const int nnn = 1048590; const int inf = numeric_limits<int>::max()-1; //const ll INF = numeric_limits<ll>::max()-1; //const ll INF = 1e18; ll dx[]={0,1,0,-1}; ll dy[]={1,0,-1,0}; ll dxx[]={0,1,0,-1,1,1,-1,-1}; ll dyy[]={1,0,-1,0,1,-1,1,-1}; const ll N = 318; ll val[maxn] , vis[maxn] , dp[maxn]; vector < ll > v[maxn], g[maxn]; vector < ii > f[maxn]; vector < ii > merge(vector <ii> &a, vector < ii > &b){ vector < ii > ans; ll p1 = 0 , p2 = 0; while(p1 + p2 < a.size() + b.size()){ if(ans.size() == N+2) break; if(p1 < a.size() && vis[a[p1].ff]){p1++; continue;} if(p2 < b.size() && vis[b[p2].ff]){p2++; continue;} if(p1 == a.size()){ vis[b[p2].ff]=1; ans.pb({b[p2++].ff ,b[p2-1].ss + 1 }) ; continue;} if(p2 == b.size()){ vis[a[p1].ff]=1; ans.pb({a[p1++].ff ,a[p1-1].ss}) ; continue;} if(b[p2].ss+1 > a[p1].ss) vis[b[p2].ff]=1, ans.pb({b[p2++].ff ,b[p2-1].ss + 1 }) ; else vis[a[p1].ff]=1, ans.pb({a[p1++].ff ,a[p1-1].ss}) ; } for(auto [u , y] : ans) vis[u] = 0; return ans; } bool comp(ll a, ll b){ return val[a] < val[b]; } void solve(){ mem(vis, 0); ll n , m , q; cin >> n >> m >> q; for(ll i = 1; i <= m; i++){ ll x , y; cin >> x >> y; v[y].pb(x); } for(ll i = 1; i <= n; i++){ val[i] = 0; f[i].pb({i, 0}); for(auto u : v[i]){ f[i] = merge(f[i] , f[u]); } // sort(f[i].begin() , f[i].end() , comp); } vector < ll > c; while(q--){ ll node , t , x; cin >> node >> t; for(auto u : c) vis[u] = 0; c.clear(); f1(t) cin >> x , c.pb(x) , vis[x] = 1; if(t >= N){ mem(dp, 0); for(auto u : c) dp[u] = -1; for(ll i = 1; i <= node; i++){ for(auto u : v[i]){ if(dp[u] == -1) continue; dp[i] = max(dp[i] , dp[u]+1); } } cout << dp[node] << '\n'; }else{ bool ok = 0; for(auto [u , y] : f[node]){ if(!vis[u]){ cout << y << '\n'; ok = 1; break; } } if(!ok) cout << "-1\n"; } } return; } int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #else // freopen("cbarn2.in", "r", stdin); // freopen("cbarn2.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); #endif //cout << fixed << setprecision(10); // work(); // mem(b,0); ll T; T=1; //cin >> T; //scanf("%lld",&T); // ll CT = 0; //work(); while(T--){ //cout << "Case " << ++CT <<": " ; //printf("Case %lld: ",++CT); solve(); } return 0; }

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

bitaro.cpp: In function 'std::vector<std::pair<int, int> > merge(std::vector<std::pair<int, int> >&, std::vector<std::pair<int, int> >&)':
bitaro.cpp:58:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   while(p1 + p2 < a.size() + b.size()){
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:60:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     if(p1 < a.size() && vis[a[p1].ff]){p1++; continue;}
      |        ~~~^~~~~~~~~~
bitaro.cpp:61:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     if(p2 < b.size() && vis[b[p2].ff]){p2++; continue;}
      |        ~~~^~~~~~~~~~
bitaro.cpp:62:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     if(p1 == a.size()){ vis[b[p2].ff]=1; ans.pb({b[p2++].ff ,b[p2-1].ss + 1 }) ; continue;}
      |        ~~~^~~~~~~~~~~
bitaro.cpp:62:54: warning: operation on 'p2' may be undefined [-Wsequence-point]
   62 |     if(p1 == a.size()){ vis[b[p2].ff]=1; ans.pb({b[p2++].ff ,b[p2-1].ss + 1 }) ; continue;}
      |                                                    ~~^~
bitaro.cpp:63:11: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     if(p2 == b.size()){ vis[a[p1].ff]=1; ans.pb({a[p1++].ff ,a[p1-1].ss}) ; continue;}
      |        ~~~^~~~~~~~~~~
bitaro.cpp:63:54: warning: operation on 'p1' may be undefined [-Wsequence-point]
   63 |     if(p2 == b.size()){ vis[a[p1].ff]=1; ans.pb({a[p1++].ff ,a[p1-1].ss}) ; continue;}
      |                                                    ~~^~
bitaro.cpp:65:36: warning: operation on 'p2' may be undefined [-Wsequence-point]
   65 |       vis[b[p2].ff]=1, ans.pb({b[p2++].ff ,b[p2-1].ss + 1 }) ;
      |                                  ~~^~
bitaro.cpp:67:36: warning: operation on 'p1' may be undefined [-Wsequence-point]
   67 |       vis[a[p1].ff]=1, ans.pb({a[p1++].ff ,a[p1-1].ss}) ;
      |                                  ~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...