#include<bits/stdc++.h>
// #include "grader.cpp"
using namespace std;
const int N = 2e5 + 100, C = 500;
int n, D, H[N];
int U, A[N], B[N];
vector<int> vec[C][N];
set<int> S[N];
void init(int NN, int DD, int HH[])
{
n = NN;
D = DD;
for(int i = 0; i < n; i++)
H[i] = HH[i];
}
void curseChanges(int u, int AA[], int BB[])
{
for(int i = 0; i < u; i++)
{
A[i + 1] = AA[i];
B[i + 1] = BB[i];
}
U = u;
for(int i = 1; i <= u; i++)
{
int a = A[i], b = B[i];
if(S[a].find(b) != S[a].end())
{
S[a].erase(b);
S[b].erase(a);
}
else
{
S[a].insert(b);
S[b].insert(a);
}
if(i % C == 0)
{
int ind = i / C;
for(int j = 0; j < n; j++)
{
for(auto h : S[j])
vec[ind][j].push_back(h);
}
}
}
// for(int i = 1; i <= 3; i++)
// {
// cout << i << " == \n";
// for(int j = 0; j < n; j++)
// {
// cout << j << " == ";
// for(auto h : vec[i][j])
// cout << h << ' ';
// cout << '\n';
// }
// cout << '\n';
// }
// exit(0);
}
set<int> S1, S2;
vector<int> V1, V2;
int question(int x, int y, int v)
{
S1.clear();
S2.clear();
V1.clear();
V2.clear();
int ind = (v / C);
for(auto i : vec[ind][x])
S1.insert(i);
for(auto i : vec[ind][y])
S2.insert(i);
ind *= C;
for(int i = ind + 1; i <= v; i++)
{
if(A[i] == x || B[i] == x)
{
int k = (A[i] == x ? B[i] : A[i]);
if(S1.find(k) != S1.end())
S1.erase(k);
else
S1.insert(k);
}
if(A[i] == y || B[i] == y)
{
int k = (A[i] == y ? B[i] : A[i]);
if(S2.find(k) != S2.end())
S2.erase(k);
else
S2.insert(k);
}
}
for(auto i : S1)
V1.push_back(H[i]);
for(auto i : S2)
V2.push_back(H[i]);
int res = 1e9;
for(auto i : V1)
{
ind = lower_bound(V2.begin(), V2.end(), i) - V2.begin();
if(ind != V2.size())
res = min(res, V2[ind] - i);
if(ind)
res = min(res, i - V2[ind - 1]);
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
/tmp/cc3K4G3R.o: in function `main':
grader.cpp:(.text.startup+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
grader.cpp:(.text.startup+0x4c): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
grader.cpp:(.text.startup+0x17a): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cout' defined in .bss._ZSt4cout section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
/tmp/cc3K4G3R.o: in function `_GLOBAL__sub_I__Z4sigHi':
grader.cpp:(.text.startup+0x248): relocation truncated to fit: R_X86_64_PC32 against `.bss'
/usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1c): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x72): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0x92): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xa7): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_internal::buf_cout_sync' defined in .bss._ZN14__gnu_internal13buf_cout_syncE section in /usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(globals_io.o)
(.text._ZNSt8ios_base4InitC2Ev+0xb2): additional relocation overflows omitted from the output
(.text._ZNSt8ios_base4InitC2Ev+0x1c6): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x260): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2e2): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x353): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x541): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5e5): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x670): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x6e9): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status