#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
// #include <atcoder/all>
#include <cstdio>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x) cerr << #x <<" "; print(x); cerr << endl;
#else
#define dbg(x)
#endif
#define sz(x) (int((x).size()))
#define len(x) (int)x.length()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define clr(x) (x).clear()
#define uniq(x) x.resize(unique(all(x)) - x.begin());
#define pb push_back
#define popf pop_front
#define popb pop_back
#define ld long double
#define ll long long
void print(long long t) {cerr << t;}
void print(int t) {cerr << t;}
void print(string t) {cerr << t;}
void print(char t) {cerr << t;}
void print(double t) {cerr << t;}
void print(unsigned long long t) {cerr << t;}
void print(long double t) {cerr << t;}
template <class T, class V> void print(pair <T, V> p);
template <class T> void print(vector <T> v);
template <class T> void print(set <T> v);
template <class T, class V> void print(map <T, V> v);
template <class T> void print(multiset <T> v);
template <class T> void print(T v[],T n) {cerr << "["; for(int i = 0; i < n; i++) {cerr << v[i] << " ";} cerr << "]";}
template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";}
template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(deque <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]";}
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// #define nl '\n'
// for random generations
// mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 myrand(131);
// for grid problems
int dx[8] = {-1,0,1,0,1,-1,1,-1};
int dy[8] = {0,1,0,-1,1,1,-1,-1};
// long long ka() {
// long long x = 0;
// bool z = false;
// while (1)
// {
// char y = getchar();
// if (y == '-')
// z = true;
// else if ('0' <= y && y <= '9')
// x = x * 10 + y - '0';
// else
// {
// if (z)
// x *= -1;
// return x;
// }
// }
// }
// lowest / (1 << 17) >= 1e5 / (1 << 18) >= 2e5 / (1 << 21) >= 1e6
void fastIO() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
}
// file in/out
void setIO(string str = "") {
fastIO();
// if (str != "") {
// freopen((str + ".in").c_str(), "r", stdin);
// freopen((str + ".out").c_str(), "w", stdout);
// }else {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
// }
}
// Indexed Set
// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int inf = 1e9;
const int N = 262149;
int n, d, h[N];
// int u, a[N], b[N];
int u;
int sz;
vector<pair<int, int>> mp[2 * N];
void init(int N, int D, int H[]) {
n = N, d = D;
for(int i = 0; i < n; i++) {
h[i] = H[i];
}
}
void upd(int l, int r, int xi, int yi, int x, int lx, int rx) {
if(lx >= r || rx <= l) {
return;
}
if(lx >= l && rx <= r) {
// if(mp[x][xi].find(h[yi]) == mp[x][xi].end()) {
// mp[x][xi].insert(h[yi]);
mp[x].push_back({xi, yi});
mp[x].push_back({yi, xi});
// }
// if(mp[x][yi].find(h[xi]) == mp[x][yi].end()) {
// mp[x][yi].insert(h[xi]);
// }
return;
}
int mid = (lx + rx) / 2;
upd(l, r, xi, yi, 2 * x + 1, lx, mid);
upd(l, r, xi, yi, 2 * x + 2, mid, rx);
}
// set<int> stt[N];
void qry(int u, int xi, int x, int lx, int rx) {
if(mp[x].find(xi) != mp[x].end()) {
for(auto i: mp[x][xi]) {
// if(stt[xi].find(i) == stt[xi].end()) {
// stt[xi].insert(i);
// }
}
}
if(rx - lx == 1) {
return;
}
int mid = (lx + rx) / 2;
if(u < mid) {
qry(u, xi, 2 * x + 1, lx, mid);
} else {
qry(u, xi, 2 * x + 2, mid, rx);
}
}
void iniit(int s) {
sz = 1;
while(sz < s) {
sz *= 2;
}
}
void curseChanges(int U, int A[], int B[]) {
u = U;
iniit(u);
map<pair<int, int>, int> open;
for(int i = 0; i < u; i++) {
if(A[i] > A[i]) swap(A[i], B[i]);
if(open.find({A[i], B[i]}) != open.end()) {
upd(open[{A[i], B[i]}], i, A[i], B[i], 0, 0, sz);
open.erase({A[i], B[i]});
} else {
open[{A[i], B[i]}] = i;
}
}
for(auto i: open) {
upd(i.second, u, i.first.first, i.first.second, 0, 0, sz);
}
}
int question(int x, int y, int v) {
return 0;
// qry(v - 1, x, 0, 0, sz);
// qry(v - 1, y, 0, 0, sz);
// if(stt[x].empty() || stt[y].empty()) {
// stt[x].clear();
// stt[y].clear();
// return inf;
// }
// int ans = inf;
// auto it = stt[y].begin();
// int lst = *stt[y].rbegin();
// for(auto i: stt[x]) {
// while(it != stt[y].end() && *it <= i) {
// ans = min(ans, abs(*it - i));
// it = next(it);
// }
// if(it != stt[y].end()) {
// ans = min(ans, abs(*it - i));
// }
// if(it != stt[y].begin()) {
// ans = min(ans, abs(*prev(it) - i));
// }
// ans = min(ans, abs(i - lst));
// }
// stt[x].clear();
// stt[y].clear();
// return ans;
}
Compilation message
potion.cpp: In function 'void qry(int, int, int, int, int)':
potion.cpp:142:12: error: 'class std::vector<std::pair<int, int> >' has no member named 'find'
142 | if(mp[x].find(xi) != mp[x].end()) {
| ^~~~
potion.cpp:143:25: error: no matching function for call to 'begin(std::pair<int, int>&)'
143 | for(auto i: mp[x][xi]) {
| ^
In file included from /usr/include/c++/10/bits/range_access.h:36,
from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from potion.cpp:2:
/usr/include/c++/10/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
90 | begin(initializer_list<_Tp> __ils) noexcept
| ^~~~~
/usr/include/c++/10/initializer_list:90:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: 'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
143 | for(auto i: mp[x][xi]) {
| ^
In file included from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from potion.cpp:2:
/usr/include/c++/10/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
51 | begin(_Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/10/bits/range_access.h:51:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::pair<int, int>]':
potion.cpp:143:25: required from here
/usr/include/c++/10/bits/range_access.h:51:50: error: 'struct std::pair<int, int>' has no member named 'begin'
51 | begin(_Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
61 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/10/bits/range_access.h:61:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::pair<int, int>]':
potion.cpp:143:25: required from here
/usr/include/c++/10/bits/range_access.h:61:56: error: 'const struct std::pair<int, int>' has no member named 'begin'
61 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
90 | begin(_Tp (&__arr)[_Nm])
| ^~~~~
/usr/include/c++/10/bits/range_access.h:90:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
143 | for(auto i: mp[x][xi]) {
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from potion.cpp:2:
/usr/include/c++/10/valarray:1214:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
1214 | begin(valarray<_Tp>& __va)
| ^~~~~
/usr/include/c++/10/valarray:1214:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: 'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
143 | for(auto i: mp[x][xi]) {
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from potion.cpp:2:
/usr/include/c++/10/valarray:1224:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
1224 | begin(const valarray<_Tp>& __va)
| ^~~~~
/usr/include/c++/10/valarray:1224:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: 'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
143 | for(auto i: mp[x][xi]) {
| ^
potion.cpp:143:25: error: no matching function for call to 'end(std::pair<int, int>&)'
In file included from /usr/include/c++/10/bits/range_access.h:36,
from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from potion.cpp:2:
/usr/include/c++/10/initializer_list:101:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)'
101 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
/usr/include/c++/10/initializer_list:101:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: 'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
143 | for(auto i: mp[x][xi]) {
| ^
In file included from /usr/include/c++/10/string:54,
from /usr/include/c++/10/bits/locale_classes.h:40,
from /usr/include/c++/10/bits/ios_base.h:41,
from /usr/include/c++/10/ios:42,
from /usr/include/c++/10/istream:38,
from /usr/include/c++/10/sstream:38,
from /usr/include/c++/10/complex:45,
from /usr/include/c++/10/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
from potion.cpp:2:
/usr/include/c++/10/bits/range_access.h:71:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:71:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::pair<int, int>]':
potion.cpp:143:25: required from here
/usr/include/c++/10/bits/range_access.h:71:48: error: 'struct std::pair<int, int>' has no member named 'end'
71 | end(_Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/10/bits/range_access.h:81:5: note: template argument deduction/substitution failed:
/usr/include/c++/10/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::pair<int, int>]':
potion.cpp:143:25: required from here
/usr/include/c++/10/bits/range_access.h:81:54: error: 'const struct std::pair<int, int>' has no member named 'end'
81 | end(const _Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
100 | end(_Tp (&__arr)[_Nm])
| ^~~
/usr/include/c++/10/bits/range_access.h:100:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
143 | for(auto i: mp[x][xi]) {
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from potion.cpp:2:
/usr/include/c++/10/valarray:1234:5: note: candidate: 'template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)'
1234 | end(valarray<_Tp>& __va)
| ^~~
/usr/include/c++/10/valarray:1234:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: 'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
143 | for(auto i: mp[x][xi]) {
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
from potion.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)'
1244 | end(const valarray<_Tp>& __va)
| ^~~
/usr/include/c++/10/valarray:1244:5: note: template argument deduction/substitution failed:
potion.cpp:143:25: note: 'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
143 | for(auto i: mp[x][xi]) {
| ^
potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:175:13: warning: self-comparison always evaluates to false [-Wtautological-compare]
175 | if(A[i] > A[i]) swap(A[i], B[i]);
| ~~~~ ^ ~~~~
potion.cpp: In function 'void setIO(std::string)':
potion.cpp:91:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
91 | freopen("input.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
potion.cpp:92:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
92 | freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~