#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;
cout << down[u] - up[u] + 1 << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
584 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
584 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
668 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
668 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
596 KB |
Output is correct |
2 |
Correct |
53 ms |
4956 KB |
Output is correct |
3 |
Correct |
48 ms |
4976 KB |
Output is correct |
4 |
Correct |
50 ms |
4928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
596 KB |
Output is correct |
2 |
Correct |
53 ms |
4956 KB |
Output is correct |
3 |
Correct |
48 ms |
4976 KB |
Output is correct |
4 |
Correct |
50 ms |
4928 KB |
Output is correct |
5 |
Incorrect |
20 ms |
1504 KB |
Extra information in the output file |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
632 KB |
Output is correct |
2 |
Correct |
55 ms |
4972 KB |
Output is correct |
3 |
Correct |
69 ms |
4960 KB |
Output is correct |
4 |
Correct |
60 ms |
4904 KB |
Output is correct |
5 |
Incorrect |
19 ms |
1472 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
632 KB |
Output is correct |
2 |
Correct |
55 ms |
4972 KB |
Output is correct |
3 |
Correct |
69 ms |
4960 KB |
Output is correct |
4 |
Correct |
60 ms |
4904 KB |
Output is correct |
5 |
Incorrect |
19 ms |
1472 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |