Submission #1120100

#TimeUsernameProblemLanguageResultExecution timeMemory
1120100JanPhamBall Machine (BOI13_ballmachine)C++17
0 / 100
42 ms29196 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define TranLeThanhTam "TranLeThanhTam" #define all(v) v.begin(),v.end() #define reset(a,i) memset(a,i,sizeof(a)) #define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; --i) #define compact(v) sort(all(v)), v.erase(unique(all(v)), end(v)) #define sz(v) (int) v.size() #define MASK(i) (1 << (i)) typedef long long ll; typedef long double lb; typedef pair<ll,ll> pll; typedef pair<int,int> pii; const int Thanh_Tam = 1e5 + 17; const int inf = 1e9 + 17; const long long infll = 1e18 + 17; const int MOD = 1e9 + 7; const int Log = 18; const int dx[4] = {-1, 0, 0, 1}; const int dy[4] = {0, -1, 1, 0}; const int max_block_size = 270; const ll P = 311; const int maxA = 1e2 + 17; const int addi = 1e9; const char dir[4] = {'W', 'S', 'N', 'E'}; const int Mod[3] = {998244353, MOD, 759186269}; ll mul(ll a, ll b, ll mod); ll binpow(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1) res = mul(res,a,mod); b >>= 1; a = mul(a,a,mod); } return res; } ll add(ll a, ll b, ll mod) { return (a + b) % mod; } ll sub(ll a, ll b, ll mod) { return (a - b + mod) % mod; } ll mul(ll a, ll b, ll mod) { return ((a % mod) * (b % mod)) % mod; } ll div(ll a, ll b, ll mod) { return mul(a, binpow(b, mod - 2, mod), mod); } mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rand_range(ll l, ll r) { return uniform_int_distribution<ll>(l,r)(rng); } struct Fenwick { vector<int> cnt; Fenwick() {} Fenwick(int _n) { cnt.assign(_n + 1, 0); return; } void update(int id, int val) { for (; id < sz(cnt); id += id & (-id)) cnt[id] += val; return; } int query(int id) { int res = 0; for (; id > 0; id -= id & (-id)) res += cnt[id]; return res; } } tree; int n, q, timer = 0; vector<int> adj[Thanh_Tam]; int tin[Thanh_Tam], tout[Thanh_Tam], tour[Thanh_Tam]; int tin_spr[Thanh_Tam], tout_spr[Thanh_Tam], tour_spr[Thanh_Tam << 1]; int spr[Thanh_Tam << 1][Log + 1]; void dfs1(int u, int Par) { tin[u] = ++timer; tour[timer] = u; for (int v : adj[u]) { if (v == Par) continue; dfs1(v,u); } tout[u] = timer; return; } void dfs2(int u, int Par) { tin_spr[u] = ++timer; tour_spr[timer] = u; for (int v : adj[u]) { if (v == Par) continue; dfs2(v,u); tour_spr[++timer] = u; } tout_spr[u] = timer; return; } void prepare() { timer = 0, dfs1(1, -1); timer = 0, dfs2(1, -1); tree = Fenwick(n); FOR(i,1,(n << 1) - 1) spr[i][0] = tour_spr[i]; FOR(j,1,Log) { } return; } void ThanhTam() { cin >> n >> q; FOR(v,1,n) { int u; cin >> u; if (v == 1) continue; adj[u].pb(v); adj[v].pb(u); } prepare(); return; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); if (fopen(TranLeThanhTam".inp","r")) { freopen(TranLeThanhTam".inp","r",stdin); freopen(TranLeThanhTam".out","w",stdout); } int t = 1; //cin >> t; while (t--) ThanhTam(); return 0; }

Compilation message (stderr)

ballmachine.cpp: In function 'int main()':
ballmachine.cpp:158:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  158 |         freopen(TranLeThanhTam".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ballmachine.cpp:159:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  159 |         freopen(TranLeThanhTam".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...