제출 #682859

#제출 시각아이디문제언어결과실행 시간메모리
682859MilosMilutinovic던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> c(n); for (int i = 0; i < n; i++) { cin >> c[i]; } vector<int> R(n); map<long long, int> mp; long long s = 0; mp[0] = n; for (int i = n - 1; i >= 0; i--) { s += c[i]; if (mp.count(s)) { R[i] = mp[s] - 1; } else { R[i] = n; } mp[s] = i; if (i + 1 < n) { R[i] = min(R[i], R[i + 1]); } } const int L = 6; vector<int> pw(1, 8); for (int i = 0; i < L; i++) { pw.push_back(pw.back() * 8); } vector<vector<int>> pos(n, vector<int>(L)); for (int i = 0; i < n; i++) { int x = R[i]; for (int j = 0; j < 7; j++) { if (x + 1 < n) { x = R[x + 1]; } else { x = n; } } pos[i][0] = x; } for (int j = 1; j < L; j++) { for (int i = 0; i < n; i++) { int x = pos[i][j - 1]; for (int iter = 0; iter < 7; iter++) { if (x + 1 < n) { x = pos[x + 1][j - 1]; } else { x = n; } } pos[i][j] = x; } } int q; cin >> q; while (q--) { int l, r; cin >> l >> r; --l; --r; int ans = 0; for (int i = L - 1; i >= 0; i--) { while (l < n && pos[l][i] <= r) { ans += pw[i]; l = pos[l][i] + 1; } } while (l < n && R[l] <= r) { ans++; l = R[l] + 1; } cout << ans << '\n'; } return 0; }

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

/usr/bin/ld: /tmp/ccR8ZZfJ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccEzacKH.o:dungeons.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccR8ZZfJ.o: in function `main':
grader.cpp:(.text.startup+0x3bd): undefined reference to `init(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x440): undefined reference to `simulate(int, int)'
collect2: error: ld returned 1 exit status