Submission #868967

# Submission time Handle Problem Language Result Execution time Memory
868967 2023-11-02T16:29:17 Z serifefedartar Tenis (COI19_tenis) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9+7;
const ll LOGN = 30; 
const ll MAXN = 1e5 + 100;
const ll MULT = 1e9;

int rank[3][MAXN];
int sg[4*MAXN], lazy[4*MAXN];
void init(int k, int a, int b) {
	if (a == b) {
		sg[k] = a;
		return ;
	}
	init(2*k, a, (a+b)/2);
	init(2*k+1, (a+b)/2+1, b);
	sg[k] = min(sg[2*k], sg[2*k+1]);
}

void push(int k, int a, int b) {
	sg[k] += lazy[k];
	if (a != b) {
		lazy[2*k] += lazy[k];
		lazy[2*k+1] += lazy[k];
	}
	lazy[k] = 0;
}

void update(int k, int a, int b, int q_l, int q_r, int val) {
	push(k, a, b);
	if (q_r < a || q_l > b)
		return ;
	if (q_l <= a && b <= q_r) {
		lazy[k] += val;
		push(k, a, b);
		return ;
	}
	update(2*k, a, (a+b)/2, q_l, q_r, val);
	update(2*k+1, (a+b)/2+1, b, q_l, q_r, val);
	sg[k] = min(sg[2*k], sg[2*k+1]);
}

int query(int k, int a, int b) {
	push(k, a, b);
	if (a == b) {
		return a;
	}
	if (sg[2*k] == 0)
		return query(2*k, a, a+b/2);
	return query(2*k+1, (a+b)/2+1, b);
}

int maxi(int x, int y, int z) {
	return max(x, max(y, z));
}

int main() {
	fast
	int N, Q;
	cin >> N >> Q;

	for (int i = 1; i <= N; i++) {
		int x; cin >> x;
		rank[0][x] = i;
	}
	for (int i = 1; i <= N; i++) {
		int x; cin >> x;
		rank[1][x] = i;
	}
	for (int i = 1; i <= N; i++) {
		int x; cin >> x;
		rank[2][x] = i;
	}
	init(1, 1, N);

	for (int i = 1; i <= N; i++)
		update(1, 1, N, maxi(rank[0][i], rank[1][i], rank[2][i]), N, -1);
	while (Q--) {
		int type;
		cin >> type;
		if (type == 1) {
			int x; cin >> x;
			if (maxi(rank[0][x], rank[1][x], rank[2][x]) <= query(1, 1, N))
				cout << "DA\n";
			else
				cout << "NE\n";
		} else {
			int p, a, b; cin >> p >> a >> b;
			update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
			update(1, 1, N, maxi(rank[0][b], rank[1][b], rank[2][b]), N, 1);
			swap(rank[p-1][a], rank[p-1][b]);
			update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
			update(1, 1, N, maxi(rank[0][b], rank[1][b], rank[2][b]), N, 1);
		}
	}
}

Compilation message

tenis.cpp: In function 'int main()':
tenis.cpp:69:3: error: reference to 'rank' is ambiguous
   69 |   rank[0][x] = i;
      |   ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:73:3: error: reference to 'rank' is ambiguous
   73 |   rank[1][x] = i;
      |   ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:77:3: error: reference to 'rank' is ambiguous
   77 |   rank[2][x] = i;
      |   ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:82:24: error: reference to 'rank' is ambiguous
   82 |   update(1, 1, N, maxi(rank[0][i], rank[1][i], rank[2][i]), N, -1);
      |                        ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:82:36: error: reference to 'rank' is ambiguous
   82 |   update(1, 1, N, maxi(rank[0][i], rank[1][i], rank[2][i]), N, -1);
      |                                    ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:82:48: error: reference to 'rank' is ambiguous
   82 |   update(1, 1, N, maxi(rank[0][i], rank[1][i], rank[2][i]), N, -1);
      |                                                ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:88:13: error: reference to 'rank' is ambiguous
   88 |    if (maxi(rank[0][x], rank[1][x], rank[2][x]) <= query(1, 1, N))
      |             ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:88:25: error: reference to 'rank' is ambiguous
   88 |    if (maxi(rank[0][x], rank[1][x], rank[2][x]) <= query(1, 1, N))
      |                         ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:88:37: error: reference to 'rank' is ambiguous
   88 |    if (maxi(rank[0][x], rank[1][x], rank[2][x]) <= query(1, 1, N))
      |                                     ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:94:25: error: reference to 'rank' is ambiguous
   94 |    update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
      |                         ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:94:37: error: reference to 'rank' is ambiguous
   94 |    update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
      |                                     ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:94:49: error: reference to 'rank' is ambiguous
   94 |    update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
      |                                                 ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:95:25: error: reference to 'rank' is ambiguous
   95 |    update(1, 1, N, maxi(rank[0][b], rank[1][b], rank[2][b]), N, 1);
      |                         ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:95:37: error: reference to 'rank' is ambiguous
   95 |    update(1, 1, N, maxi(rank[0][b], rank[1][b], rank[2][b]), N, 1);
      |                                     ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:95:49: error: reference to 'rank' is ambiguous
   95 |    update(1, 1, N, maxi(rank[0][b], rank[1][b], rank[2][b]), N, 1);
      |                                                 ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:96:9: error: reference to 'rank' is ambiguous
   96 |    swap(rank[p-1][a], rank[p-1][b]);
      |         ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:96:23: error: reference to 'rank' is ambiguous
   96 |    swap(rank[p-1][a], rank[p-1][b]);
      |                       ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:97:25: error: reference to 'rank' is ambiguous
   97 |    update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
      |                         ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:97:37: error: reference to 'rank' is ambiguous
   97 |    update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
      |                                     ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:97:49: error: reference to 'rank' is ambiguous
   97 |    update(1, 1, N, maxi(rank[0][a], rank[1][a], rank[2][a]), N, 1);
      |                                                 ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:98:25: error: reference to 'rank' is ambiguous
   98 |    update(1, 1, N, maxi(rank[0][b], rank[1][b], rank[2][b]), N, 1);
      |                         ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tenis.cpp:1:
/usr/include/c++/10/type_traits:1359:12: note: candidates are: 'template<class> struct std::rank'
 1359 |     struct rank
      |            ^~~~
tenis.cpp:13:5: note:                 'int rank [3][100100]'
   13 | int rank[3][MAXN];
      |     ^~~~
tenis.cpp:98:37: error: reference to 'rank' is ambiguous
   98 |    update(1, 1, N, maxi(rank[0][b], rank[1][b], rank[2][b]), N, 1);
      |                                     ^~~~
In file included from /usr/include/c++/10/bits/move.h:57,
                 from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from /var/local/lib