제출 #283217

#제출 시각아이디문제언어결과실행 시간메모리
283217AKaan37Ball Machine (BOI13_ballmachine)C++17
20.95 / 100
1099 ms29048 KiB
//Bismillahirrahmanirrahim //█▀█─█──█──█▀█─█─█ //█▄█─█──█──█▄█─█▄█ //█─█─█▄─█▄─█─█─█─█ #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx2") #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define mp make_pair #define endl "\n" #define int long long #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 500005; const lo mod = 1000000007; int n,m,b[li],a[li],k,flag,t,vis[li],root,par[li][LOG],last; int cev; set<int> st; string s; vector<int> v; inline void build_lca(){ for(int i=1;i<=17;i++){ for(int j=1;j<=n;j++)par[j][i]=par[par[j][i-1]][i-1]; } } int32_t main(void){ scanf("%lld %lld",&n,&t); FOR{ int x; scanf("%lld",&x); if(x==0){ root=x; } else{ vis[x]++; par[i][0]=x; } } FOR{ if(vis[i]==0)st.insert(i); } build_lca(); vis[0]=1000000; while(t--){ int type; scanf("%lld",&type); if(type==1){ scanf("%lld",&k); while(k){ k--; auto it=st.begin(); last=*it; //~ cout<<last<<endl; vis[par[*it][0]]--; if(vis[par[*it][0]]==0)st.insert(par[*it][0]); st.erase(it); } printf("%lld\n",last); continue; } int x; scanf("%lld",&x); int y=x; cev=0; for(int i=17;i>=0;i--){ if(vis[par[x][i]] || st.find(par[x][i])!=st.end())continue; x=par[x][i]; cev+=(1<<i); } if(st.find(par[x][0])!=st.end())st.erase(par[x][0]); vis[par[x][0]]++; st.insert(x); printf("%lld\n",cev); } return 0; }

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

ballmachine.cpp: In function 'int32_t main()':
ballmachine.cpp:84:7: warning: unused variable 'y' [-Wunused-variable]
   84 |   int y=x;
      |       ^
ballmachine.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |  scanf("%lld %lld",&n,&t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
ballmachine.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |   scanf("%lld",&x);
      |   ~~~~~^~~~~~~~~~~
ballmachine.cpp:67:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   67 |   scanf("%lld",&type);
      |   ~~~~~^~~~~~~~~~~~~~
ballmachine.cpp:69:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |    scanf("%lld",&k);
      |    ~~~~~^~~~~~~~~~~
ballmachine.cpp:83:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   83 |   scanf("%lld",&x);
      |   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...