제출 #1098315

#제출 시각아이디문제언어결과실행 시간메모리
1098315vjudge1다리 (APIO19_bridges)C++17
16 / 100
534 ms17664 KiB
//UNSTOPPABLE #include "bits/stdc++.h" #include <ext/pb_ds/assoc_container.hpp> #define ll long long #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define int long long #define F first #define S second #define all(x) (x).begin(), (x).end() #define pii pair<int,int> #define sigma signed #define tpii pair <pair <int,int> , int> #define bruh cout << "NO\n" using namespace std; using namespace __gnu_pbds; const int N = 3e5 + 5; int mod = 1e9 + 7; const int INF = 1e18; int n,m,q,t[4 * N]; vector <pii> g[N]; void upd(int pos , int x , int v = 1 , int tl = 1 , int tr = n){ if(tl > pos || tr < pos) return; if(tl == pos && tr == pos){ t[v] = x; return; } int tm = tl + tr >> 1; upd(pos , x , v * 2 , tl , tm); upd(pos , x , v * 2 + 1 , tm + 1 , tr); t[v] = min(t[v * 2] , t[v * 2 + 1]); } int get(int l , int r , int v = 1 , int tl = 1 , int tr = n){ if(tl > r || tr < l) return INF; if(tl >= l && tr <= r) return t[v]; int tm = tl + tr >> 1; return min(get(l , r , v * 2 , tl , tm) , get(l , r , v * 2 + 1 , tm + 1 , tr)); } void Goldik(){ cin >> n >> m; set <int> st; map <int,int> mp; for(int i = 1 ; i <= m ; i++){ int u,v,w; cin >> u >> v >> w; g[u].pb({v , w}); g[v].pb({u , w}); upd(u , w); } cin >> q; for(int i = 1 ; i <= q ; i++){ int tp,u,v; cin >> tp >> u >> v; if(tp == 1){ upd(u , v); } else{ int l = 1 , r = u - 1 , res = u; while(l <= r){ int md = l + r >> 1; if(get(md , u - 1) < v){ l = md + 1; } else{ res = md; r = md - 1; } } l = u + 1 , r = n ; int res1 = u; while(l <= r){ int md = l + r >> 1; if(get(u , md - 1) < v){ r = md - 1; } else{ res1 = md; l = md + 1; } } cout << res1 - res + 1 << '\n'; } } } //rewai mnogo zadach vozmozhno odna iz nih gde to popadetsya //returning winter prime? //chem prowe tem luchshe sigma main(/*AZ AZDAN UZDIKSIZ*/){ //freopen("txt.in","r",stdin); //freopen("txt.out","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); srand(time(0)); int TT = 1; // cin >> TT; for(int i = 1 ; i <= TT ; i++){ //cout << "Case " << i << ": "; Goldik(); } }

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

bridges.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int)':
bridges.cpp:30:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |  int tm = tl + tr >> 1;
      |           ~~~^~~~
bridges.cpp: In function 'long long int get(long long int, long long int, long long int, long long int, long long int)':
bridges.cpp:38:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |  int tm = tl + tr >> 1;
      |           ~~~^~~~
bridges.cpp: In function 'void Goldik()':
bridges.cpp:63:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |     int md = l + r >> 1;
      |              ~~^~~
bridges.cpp:74:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   74 |     int md = l + r >> 1;
      |              ~~^~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...