Submission #545579

# Submission time Handle Problem Language Result Execution time Memory
545579 2022-04-04T22:55:14 Z Zhora_004 Inside information (BOI21_servers) C++17
10 / 100
72 ms 4624 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
//#include <bit>
//#include <ranges>
//#include <numbers>
#define itn int
#define sacnf scanf
#define sz(a) ((int)((a).size()))
// printf("%.10f\n", ans);
using ll = long long;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 1, inf = 1e9;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> up(n + 1), down(n + 1);
    for (int i = 1; i <= n; i++) up[i] = down[i] = i;
    for (int i = 0; i < n + k - 1; i++)
    {
        char s;
        cin >> s;
        if (s == 'S')
        {
            int u, v;
            cin >> u >> v;
            if (u > v) swap(u, v);
            up[v] = up[u];
            down[u] = down[v];
        }
        else if (s == 'Q')
        {
            int u, v;
            cin >> u >> v;
            if (u >= v && up[u] <= v) cout << "yes\n";
            else if (u < v && down[u] >= v) cout << "yes\n";
            else cout << "no\n";
        }
        else
        {
            int u;
            cin >> u;
            int l = 0, r = u;
            while (l + 1 < r)
            {
                int m = (l + r) >> 1;
                if (down[m] >= u) r = m;
                else l = m;
            }
            int a = r;
            l = u, r = n + 1;
            while (l + 1 < r)
            {
                int m = (l + r) >> 1;
                if (up[m] <= u) l = m;
                else r = m;
            }
            cout << l - a + 1 << "\n";
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 724 KB Output is correct
2 Correct 57 ms 1768 KB Output is correct
3 Correct 64 ms 1800 KB Output is correct
4 Correct 58 ms 1708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 724 KB Output is correct
2 Correct 57 ms 1768 KB Output is correct
3 Correct 64 ms 1800 KB Output is correct
4 Correct 58 ms 1708 KB Output is correct
5 Correct 19 ms 628 KB Output is correct
6 Correct 50 ms 4496 KB Output is correct
7 Correct 52 ms 4624 KB Output is correct
8 Correct 57 ms 4044 KB Output is correct
9 Correct 52 ms 4044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 700 KB Output is correct
2 Correct 46 ms 1804 KB Output is correct
3 Correct 50 ms 1824 KB Output is correct
4 Correct 72 ms 1784 KB Output is correct
5 Incorrect 18 ms 724 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 700 KB Output is correct
2 Correct 46 ms 1804 KB Output is correct
3 Correct 50 ms 1824 KB Output is correct
4 Correct 72 ms 1784 KB Output is correct
5 Incorrect 18 ms 724 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -