제출 #1298558

#제출 시각아이디문제언어결과실행 시간메모리
1298558hssaan_arifVinjete (COI22_vinjete)C++20
11 / 100
3115 ms440712 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define pb push_back #define int long long #define fi first #define se second const int N = 3e5 + 5, M = 1e9 + 7, LG = 20; int n , A[N] , fen[N] , cnt[N] , u , v, l , r , m , val , ANS[N]; vector<vector<int>> lis[N]; map<int,int> cn; // void add(int i , int x){ // while(i <= n){ // cnt[i]+=x; // fen[i]+=x; // i += (i&(-i)); // } // } // int prep(int i){ // int su = 0 , re = 0; // while (i > 0){ // su += fen[i]; // re += cnt[i]; // i -= (i&(-i)); // } // return su; // } void dfs(int v , int p){ for (auto u : lis[v]){ if (u[0] == p) continue; for (int j=u[1] ; j <= u[2] ; j++){ cn[j]++; if (cn[j] == 1){ val++; } } ANS[u[0]] = val; dfs(u[0] , v); for (int j=u[1] ; j <= u[2] ; j++){ cn[j]--; if (cn[j] == 0){ val--; } } } } void solve(){ cin >> n >> m; for (int i=1 ; i<=n ; i++){ cin >> u >> v >> l >> r; lis[u].pb({v,l,r}); lis[v].pb({u,l,r}); } dfs(1 , 1); for (int i=2 ; i<=n ; i++){ cout << ANS[i] << endl; } } signed main(){ for (int i=1 ; i<N ; i++){ int j = i; while(j < N){ fen[j] += 1; cnt[j] -= 1; j += (j&(-j)); } } // freopen("" , "r" , stdin); // freopen("" , "w" , stdout); // cout << setprecision(30); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ts = 1; // cin >> ts; while(ts--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...