QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137725 | #6343. Bitaro's travel | Asymmetry# | Compile Error | / | / | C++14 | 2.3kb | 2023-08-10 17:07:01 | 2024-07-04 01:30:15 |
Judging History
你现在查看的是最新测评结果
- [2024-07-04 01:30:15]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-08-10 17:07:01]
- 提交
answer
using LL=long long;
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#ifdef DEBUG
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<int> t(n);
REP (i, n)
cin >> t[i];
auto find_start = [&](int x) {
int ind = int(upper_bound(t.begin(), t.end(), x) - t.begin());
int ret = 0;
if (ind < n && abs(t[ret] - x) > abs(t[ind] - x))
ret = ind;
if (ind && abs(t[ret] - x) >= abs(t[ind - 1] - x))
ret = ind - 1;
return ret;
};
const int INF = int(1e9);
auto dist = [&](int p, int q) {
if (p < 0 || q < 0 || p >= n || q >= n)
return INF;
return abs(t[p] - t[q]);
};
debug(t);
vector<int> start_lf(n, -2), start_rg(n, n + 1);
FOR (i, 1, n - 1)
FOR (j, i, n - 1)
if (t[j] - t[i] >= t[i] - t[i - 1]) {
start_lf[i] = j;
break;
}
debug(start_lf);
REP (i, n - 1)
for (int j = i; j >= 0; --j)
if (t[i] - t[j] > t[i + 1] - t[i]) {
start_rg[i] = j;
break;
}
debug(start_rg);
// return 0;
int q;
cin >> q;
REP (xd, q) {
int x;
cin >> x;
int cur = find_start(x);
LL ans = abs(t[cur] - x);
int lf = cur, rg = cur;
int side = dist(cur - 1, cur) <= dist(cur, cur + 1);
int cnt = 0;
while (lf || rg < n - 1) {
++cnt;
assert(cnt < 100);
debug(lf, rg, side);
if (side) {
// idziemy w lewo
int poz = 0;
REP (i, lf)
if (start_lf[i] > rg + 1)
poz = i;
debug(poz);
ans += dist(lf, poz);
lf = poz;
if (rg < n - 1) {
ans += dist(lf, rg + 1);
++rg;
side ^= 1;
}
}
else {
// idziemy w prawo
int poz = n - 1;
FOR (i, rg, n - 1)
if (start_rg[i] < lf - 1) {
poz = i;
break;
}
debug(poz);
ans += dist(rg, poz);
rg = poz;
if (lf) {
ans += dist(rg, lf - 1);
--lf;
side ^= 1;
}
}
}
cout << ans << '\n';
}
}
Details
answer.code:5:31: error: declaration of ‘operator<<’ as non-function 5 | template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} | ^~~~~~~~ answer.code:5:42: error: ‘ostream’ was not declared in this scope 5 | template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} | ^~~~~~~ answer.code:5:50: error: ‘o’ was not declared in this scope 5 | template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} | ^ answer.code:5:52: error: ‘pair’ was not declared in this scope 5 | template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} | ^~~~ answer.code:5:58: error: expected primary-expression before ‘,’ token 5 | template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} | ^ answer.code:5:60: error: expected primary-expression before ‘>’ token 5 | template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} | ^ answer.code:5:61: error: ‘p’ was not declared in this scope 5 | template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';} | ^ answer.code:6:23: error: declaration of ‘operator<<’ as non-function 6 | template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';} | ^~~~~~~~ answer.code:6:34: error: ‘ostream’ was not declared in this scope 6 | template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';} | ^~~~~~~ answer.code:6:42: error: ‘o’ was not declared in this scope 6 | template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';} | ^ answer.code:6:46: error: expected primary-expression before ‘x’ 6 | template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';} | ^ answer.code: In function ‘int main()’: answer.code:14:9: error: ‘cin’ was not declared in this scope 14 | cin.tie(0)->sync_with_stdio(0); | ^~~ answer.code:17:9: error: ‘vector’ was not declared in this scope 17 | vector<int> t(n); | ^~~~~~ answer.code:17:16: error: expected primary-expression before ‘int’ 17 | vector<int> t(n); | ^~~ answer.code:19:24: error: ‘t’ was not declared in this scope 19 | cin >> t[i]; | ^ answer.code: In lambda function: answer.code:22:43: error: ‘t’ was not declared in this scope 22 | int ind = int(upper_bound(t.begin(), t.end(), x) - t.begin()); | ^ answer.code:22:31: error: ‘upper_bound’ was not declared in this scope 22 | int ind = int(upper_bound(t.begin(), t.end(), x) - t.begin()); | ^~~~~~~~~~~ answer.code:24:32: error: ‘abs’ was not declared in this scope 24 | if (ind < n && abs(t[ret] - x) > abs(t[ind] - x)) | ^~~ answer.code:26:28: error: ‘abs’ was not declared in this scope 26 | if (ind && abs(t[ret] - x) >= abs(t[ind - 1] - x)) | ^~~ answer.code: In lambda function: answer.code:35:28: error: ‘t’ was not declared in this scope 35 | return abs(t[p] - t[q]); | ^ answer.code:35:24: error: ‘abs’ was not declared in this scope 35 | return abs(t[p] - t[q]); | ^~~ answer.code: In function ‘int main()’: answer.code:40:16: error: expected primary-expression before ‘int’ 40 | vector<int> start_lf(n, -2), start_rg(n, n + 1); | ^~~ answer.code:43:29: error: ‘t’ was not declared in this scope 43 | if (t[j] - t[i] >= t[i] - t[i - 1]) { | ^ answer.code:44:33: error: ‘start_lf’ was not declared in this scope 44 | start_lf[i] = j; | ^~~~~~~~ answer.code:51:29: error: ‘t’ was not declared in this sc...