답안 #557544

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
557544 2022-05-05T12:52:58 Z Mounir Inside information (BOI21_servers) C++14
10 / 100
357 ms 7712 KB
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define print(x) cout << #x << " est " << x << endl;
#define x first
#define y second
#define int long long
using namespace std;
 
const int N = 2e5;
int deb[N], fin[N];
int sum[2 * N];
int getSum(int g, int d){
      if (d < g) return 0;
      if (g%2 == 1) return sum[g] + getSum(g + 1, d);
      if (d%2 == 0) return sum[d] + getSum(g, d - 1);
      return getSum(g/2, d/2);
}

void upd(int i, int d){
      for (int nod = i; nod > 0; nod /= 2)
            sum[nod] += d;
}

void changeEtat(int i, int d){
      upd(N + deb[i], d);
      upd(N + fin[i], -d);
}
 
signed main(){  
      int nServs, nReqs; cin >> nServs >> nReqs;
      for (int i = 1; i <= nServs; ++i){
            deb[i] = i, fin[i] = i + 1;
            changeEtat(i, 1);
      }
      nReqs += nServs - 1;
      while (nReqs--){
            char typeReq; cin >> typeReq;
            if (typeReq == 'S'){
                  int a, b; cin >> a >> b;
                  changeEtat(a, -1);
                  changeEtat(b, -1);
                  int d = min(deb[a], deb[b]), f = max(fin[a], fin[b]);
                  deb[a] = deb[b] = d;
                  fin[a] = fin[b] = f;
                  changeEtat(a, 1);
                  changeEtat(b, 1);
            }
            else if (typeReq == 'Q'){
                  int a, d; cin >> a >> d;
                  if (deb[a] <= d && d < fin[a]) cout << "yes" << endl;
                  else cout << "no" << endl;
            }
            else {
                  int d; cin >> d;
                  cout << getSum(N, N + d) << endl;
            }
      }
      return 0;   
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 189 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 189 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 202 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 202 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 196 ms 588 KB Output is correct
2 Correct 346 ms 4576 KB Output is correct
3 Correct 333 ms 4472 KB Output is correct
4 Correct 307 ms 7692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 196 ms 588 KB Output is correct
2 Correct 346 ms 4576 KB Output is correct
3 Correct 333 ms 4472 KB Output is correct
4 Correct 307 ms 7692 KB Output is correct
5 Correct 191 ms 1560 KB Output is correct
6 Correct 347 ms 7320 KB Output is correct
7 Correct 336 ms 7464 KB Output is correct
8 Correct 332 ms 7040 KB Output is correct
9 Correct 312 ms 6932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 205 ms 840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 205 ms 840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 616 KB Output is correct
2 Correct 357 ms 4524 KB Output is correct
3 Correct 317 ms 4480 KB Output is correct
4 Correct 330 ms 7712 KB Output is correct
5 Incorrect 192 ms 1556 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 616 KB Output is correct
2 Correct 357 ms 4524 KB Output is correct
3 Correct 317 ms 4480 KB Output is correct
4 Correct 330 ms 7712 KB Output is correct
5 Incorrect 192 ms 1556 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 206 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 206 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -