제출 #1135691

#제출 시각아이디문제언어결과실행 시간메모리
1135691mychecksedadPassport (JOI23_passport)C++17
컴파일 에러
0 ms0 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 2e5+100, M = 1e5+10, K = 22, MX = 30; int n, L[N], R[N], q, DP[N][N], rmq[N][K][2], up[N][K][2]; set<int> S[N]; vi dist(N, MOD); void add(int l, int r, int ql, int qr, int k, int idx){ if(ql > r || l > qr) return; if(ql <= l && r <= qr){ S[k].insert(idx); return; } int m = l+r>>1; add(l, m, ql, qr, k<<1, idx); add(m+1, r, ql, qr, k<<1|1, idx); } void destroy(int l, int r, int ql, int qr, int k, int idx){ if(ql > r || l > qr) return; if(ql <= l && r <= qr){ S[k].erase(idx); return; } int m = l+r>>1; destroy(l, m, ql, qr, k<<1, idx); destroy(m+1, r, ql, qr, k<<1|1, idx); } vi TO; void rem(int l, int r, int p, int k){ for(auto c: S[k]){ if(dist[c] > dist[p] + 1){ dist[c] = dist[p] + 1; TO.pb(c); } } if(l == r){ return; } int m = l + r >> 1; if(p <= m){ rem(l, m, p, k<<1); }else{ rem(m+1, r, p, k<<1|1); } } int get(int l, int r){ int k = int(log2(r-l+1)); return R[rmq[k][k][0]] > R[rmq[r-(1<<k)+1][k][0]] ? rmq[l][k][0] : rmq[r-(1<<k)+1][k][0]; } int get2(int l, int r){ int k = int(log2(r-l+1)); return L[rmq[k][k][1]] < L[rmq[r-(1<<k)+1][k][1]] ? rmq[l][k][1] : rmq[r-(1<<k)+1][k][1]; } void solve(){ cin >> n; vector<pii> v; for(int i = 1; i <= n; ++i){ cin >> L[i] >> R[i]; rmq[i][0][0] = i; rmq[i][0][1] = i; } for(int j = 1; j < K; ++j){ for(int i = 1; i + (1<<j) <= n+1; ++i){ rmq[i][j][0] = R[rmq[i][j-1][0]] > R[rmq[i+(1<<(j-1))][j-1][0]] ? rmq[i][j-1][0] : rmq[i+(1<<(j-1))][j-1][0]; rmq[i][j][1] = L[rmq[i][j-1][1]] < L[rmq[i+(1<<(j-1))][j-1][1]] ? rmq[i][j-1][1] : rmq[i+(1<<(j-1))][j-1][1]; } } for(int i = 1; i <= n; ++i){ up[i][0][0] = get(L[i], R[i]); up[i][0][1] = get2(L[i], R[i]); if(R[up[i][0][0]] == R[i]) up[i][0][0] = i; if(L[up[i][0][1]] == L[i]) up[i][0][1] = i; } for(int j = 1; j < K; ++j){ for(int i = 1; i <= n; ++i){ up[i][j][0] = up[up[i][j - 1][0]][j - 1][0]; up[i][j][1] = up[up[i][j - 1][1]][j - 1][1]; } } vi go(n + 1); for(int i = 1; i <= n; ++i){ go[i] = 1; bool bad = 0; int v = i; for(int j = K-1; j >= 0; --j){ if(R[up[v][j][0]] < n){ v = up[v][j][0]; go[i] += (1<<j); } } if(R[v] == n) go[i] += 0; else go[i]++; if(R[up[v][0][0]] < n) bad = 1; v = i; for(int j = K-1; j >= 0; --j){ if(L[up[v][j][1]] > 1){ v = up[v][j][1]; go[i] += (1<<j); } } if(L[v] == 1) go[i] += 0; else go[i]++; if(L[up[v][0][1]] > 1) bad = 1; if(bad) go[i] = MOD; } priority_queue<pair<ll, int>> Q; vector<bool> vis(n + 1); for(int i = 1; i <= n; ++i){ add(1, n, L[i], R[i], 1, i); dist[i] = go[i]; Q.push({-dist[i], i}); } while(!Q.empty()){ int v = Q.top().ss; Q.pop(); if(vis[v]) continue; vis[v] = 1; rem(1, n, v, 1); for(int x: TO){ destroy(1, n, L[x], R[x], 1, x); Q.push({-dist[x], x}); } TO.clear(); } // en; cin >> q; for(int i = 1; i <= q; ++i){ int v; cin >> v; cout << (dist[v] >= MOD ? -1 : dist[v]) << '\n'; } } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

/tmp/ccckYhvv.o: in function `get(int, int)':
passport.cpp:(.text+0x555): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccckYhvv.o
/tmp/ccckYhvv.o: in function `get2(int, int)':
passport.cpp:(.text+0x5e6): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/ccckYhvv.o
/tmp/ccckYhvv.o: in function `solve()':
passport.cpp:(.text+0x829): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccckYhvv.o
passport.cpp:(.text+0x830): 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)
passport.cpp:(.text+0x85d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccckYhvv.o
passport.cpp:(.text+0x874): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/ccckYhvv.o
passport.cpp:(.text+0x87b): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccckYhvv.o
passport.cpp:(.text+0x88b): 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)
passport.cpp:(.text+0x8ae): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccckYhvv.o
passport.cpp:(.text+0x8ea): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/ccckYhvv.o
passport.cpp:(.text+0x8f1): additional relocation overflows omitted from the output
/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+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
collect2: error: ld returned 1 exit status