제출 #1012247

#제출 시각아이디문제언어결과실행 시간메모리
1012247YassineBenYounesBitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms4956 KiB
#include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pbds tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) int dx[8] = {1, 0, 0, -1, 1, 1, -1, -1}; int dy[8] = {0, 1, -1, 0, 1, -1, -1, 1}; #define endl "\n" #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ////////////////////Only Clear Code////////////////////////// void usaco_problem(){ freopen("milkvisits.in", "r", stdin); freopen("milkvisits.out", "w", stdout); } void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } //#define int ll const int mx = 1e5 + 5; const int LOG = 25; const int inf = 1e9; const ll mod = 998244353; const int sq = 350; vi graph[mx]; vii far[mx]; bool taken[mx]; vii merge(vii a, vii b){ int x = 0, y = 0; vii ans; for(pii p : a){ taken[p.ss] = 0; } for(pii p : b){ taken[p.ss] = 0; } for(int i = 0 ; i < b.size();i++){ b[i].ff += 1; } while(x < a.size() && y < b.size()){ if(a[x].ff > b[y].ff){ ans.pb(a[x]); x++; }else{ ans.pb(b[y]); y++; } } while(x < a.size()){ ans.pb(a[x]); x++; } while(y < b.size()){ ans.pb(b[y]); y++; } vii k; for(int i = 0;i < ans.size() && k.size() <= sq;i++){ if(taken[ans[i].ss])continue; k.pb({ans[i].ff, ans[i].ss}); taken[ans[i].ss] = 1; } return k; } bool no[mx]; int ans = 0; void dfs(int node, int c){ if(!no[node])ans = max(ans, c); for(int adj : graph[node]){ dfs(adj, c+1); } } int main(){ speed; int n,m,q;cin>>n>>m>>q; for(int i = 0;i < m;i++){ int a, b;cin >> a >> b; graph[b].pb(a); } far[1].pb({0, 1}); for(int i = 2;i <= n;i++){ far[i].pb({0, i}); for(int adj : graph[i]){ far[i] = merge(far[i], far[adj]); }/*cout << i << endl; for(pii p : far[i]){ cout << p.ff << " " << p.ss << endl; }*/ } while(q--){ int st, k;cin >> st >> k; if(k < 0){ vi v; for(int i = 0; i < k;i++){ int a;cin >> a;v.pb(a); no[a] = 1; } for(int i = 0; i < far[st].size();i++){ int nd = far[st][i].ss; if(!no[nd]){ cout << far[st][i].ff << endl; break; } } for(int i = 0; i < k;i++){ no[v[i]] = 0; } } else{ vi v; for(int i = 0; i < k;i++){ int a;cin >> a;v.pb(a); no[a] = 1; } ans = 0; dfs(st, 0); cout << ans << endl; for(int i = 0; i < k;i++){ no[v[i]] = 0; } } } } /* NEVER GIVE UP! DOING SMTHNG IS BETTER THAN DOING NTHNG!!! Your Guide when stuck: - Continue keyword only after reading the whole input - Don't use memset with testcases - Check for corner cases(n=1, n=0) - Check where you declare n(Be careful of declaring it globally and in main) */

컴파일 시 표준 에러 (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:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i = 0 ; i < b.size();i++){
      |                     ~~^~~~~~~~~~
bitaro.cpp:70:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     while(x < a.size() && y < b.size()){
      |           ~~^~~~~~~~~~
bitaro.cpp:70:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     while(x < a.size() && y < b.size()){
      |                           ~~^~~~~~~~~~
bitaro.cpp:79:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     while(x < a.size()){
      |           ~~^~~~~~~~~~
bitaro.cpp:83:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     while(y < b.size()){
      |           ~~^~~~~~~~~~
bitaro.cpp:88:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |     for(int i = 0;i < ans.size() && k.size() <= sq;i++){
      |                   ~~^~~~~~~~~~~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:130:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  130 |             for(int i = 0; i < far[st].size();i++){
      |                            ~~^~~~~~~~~~~~~~~~
bitaro.cpp: In function 'void usaco_problem()':
bitaro.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen("milkvisits.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen("milkvisits.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp: In function 'void init()':
bitaro.cpp:39:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:41:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...