Submission #598396

# Submission time Handle Problem Language Result Execution time Memory
598396 2022-07-18T08:43:20 Z gagik_2007 Inside information (BOI21_servers) C++17
5 / 100
280 ms 4376 KB
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;

string findSum(string str1, string str2)
{
    if (str1.length() > str2.length())
        swap(str1, str2);
    string str = "";
    int n1 = str1.length(), n2 = str2.length();
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());
    int carry = 0;
    for (int i = 0; i < n1; i++)
    {
        int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
        str.push_back(sum % 10 + '0');
        carry = sum / 10;
    }
    for (int i = n1; i < n2; i++)
    {
        int sum = ((str2[i] - '0') + carry);
        str.push_back(sum % 10 + '0');
        carry = sum / 10;
    }
    if (carry)
        str.push_back(carry + '0');
    reverse(str.begin(), str.end());
    return str;
}
bool isSmaller(string str1, string str2)
{
    int n1 = str1.length(), n2 = str2.length();
    if (n1 < n2)
        return true;
    if (n2 < n1)
        return false;
    for (int i = 0; i < n1; i++)
        if (str1[i] < str2[i])
            return true;
        else if (str1[i] > str2[i])
            return false;
    return false;
}
string findDiff(string str1, string str2)
{
    if (isSmaller(str1, str2))
        swap(str1, str2);
    string str = "";
    int n1 = str1.length(), n2 = str2.length();
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());
    int carry = 0;
    for (int i = 0; i < n2; i++) {
        int sub
            = ((str1[i] - '0') - (str2[i] - '0') - carry);
        if (sub < 0) {
            sub = sub + 10;
            carry = 1;
        }
        else
            carry = 0;
        str.push_back(sub + '0');
    }
    for (int i = n2; i < n1; i++) {
        int sub = ((str1[i] - '0') - carry);
        if (sub < 0) {
            sub = sub + 10;
            carry = 1;
        }
        else
            carry = 0;
        str.push_back(sub + '0');
    }
    reverse(str.begin(), str.end());
    return str;
}

typedef long long ll;
typedef long double ld;
typedef ll itn;

#define ff first
#define ss second

ll ttt;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 32768;
const ll N = 100007;
ll n, m, k;
ll t[200007];
ll timer = 1;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n + k - 1; i++) {
        char typ;
        cin >> typ;
        if (typ == 'S') {
            ll x, y;
            cin >> x >> y;
            t[x + y - 1] = timer++;
        }
        else if (typ == 'Q') {
            ll x, y;
            cin >> x >> y;
            if (x == y)cout << "yes\n";
            else if (x == 1) {
                cout << (t[y] ? "yes" : "no") << endl;
            }
            else if (y == 1) {
                cout << (t[x] ? "yes" : "no") << endl;
            }
            else if (!t[x] || !t[y] || (t[y] >= t[x])) {
                cout << "no\n";
            }
            else cout << "yes\n";
        }
        else {
            ll x;
            cin >> x;
            if (x != 1 && !t[x]) {
                cout << 1 << endl;
            }
            else {
                cout << timer - t[x] + 1 - (x == 1) << endl;
            }
        }
    }
}

/*
6 13
C 1
S 1 2
S 1 3
C 3
C 4
S 1 4
Q 5 1
C 1
S 1 5
S 1 6
Q 5 1
Q 1 5
Q 4 5
Q 6 5
Q 5 5
C 2
C 5
C 6
*/
# Verdict Execution time Memory Grader output
1 Incorrect 180 ms 832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 180 ms 832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 188 ms 1604 KB Output is correct
2 Correct 280 ms 1876 KB Output is correct
3 Correct 268 ms 4376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 1604 KB Output is correct
2 Correct 280 ms 1876 KB Output is correct
3 Correct 268 ms 4376 KB Output is correct
4 Correct 186 ms 1600 KB Output is correct
5 Correct 264 ms 4368 KB Output is correct
6 Correct 226 ms 3648 KB Output is correct
7 Correct 234 ms 3684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 201 ms 812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 201 ms 812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 208 ms 824 KB Output isn't correct
2 Halted 0 ms 0 KB -