QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296073 | #1418. Mountain Rescue Team | 17 | Compile Error | / | / | C++20 | 4.3kb | 2024-01-02 07:36:03 | 2024-01-02 07:36:03 |
Judging History
answer
bool g = false;
map<pair<int, int>, int> m;
template<class F>
vector<int> smawk(int h, int w, F f){
auto dfs = [&](auto self, vector<int> &row, vector<int> &col) -> vector<int>{
int n = row.size();
if(n == 0) return {};
vector<int> ncol;
ncol.reserve(n);
for(int i:col){
int mi = 2e9, ma = -2e9;
for(int j = 0; j < 10; j++){
for(int k = 0; k < 10; k++){
auto p = f(row[ncol.size()-1]-j, i+k, 1);
if(m.count({p/1000, p%1000})) ma = max(ma, m[{p/1000, p%1000}]);
}
}
if(ma == -2e9) ma = 2e9;
for(int j = 0; j < 10; j++){
for(int k = 0; k < 10; k++){
auto p = f(row[ncol.size()-1]+j, ncol.back()-k, 1);
if(m.count({p/1000, p%1000})) mi = min(mi, m[{p/1000, p%1000}]);
}
}
if(mi == 2e9) mi = -2e9;
while(!ncol.empty() && i != ncol.back() && ma > mi && f(row[ncol.size()-1], ncol.back()) > f(row[ncol.size()-1], i)) ncol.pop_back();
if(ncol.size() < n) ncol.push_back(i);
}
vector<int> row_odd;
row_odd.reserve(n/2+1);
for(int i = 1; i < n; i+=2) row_odd.push_back(row[i]);
vector<int> ans = self(self, row_odd, ncol);
vector<int> res(n);
for(int i = 0; i < row_odd.size(); i++) res[i*2+1] = ans[i];
int j = 0;
for(int i = 0; i < n; i+=2){
int last = (i == n-1 ? ncol.back() : res[i+1]);
res[i] = ncol[j];
while(ncol[j] < last){
++j;
if(f(row[i], res[i]) > f(row[i], ncol[j])) res[i] = ncol[j];
}
}
return res;
};
vector<int> row(h), col(w);
iota(row.begin(), row.end(), 0);
iota(col.begin(), col.end(), 0);
return dfs(dfs, row, col);
}
void Rescue(int R, int C, int RS, int CS, int X){
int l1 = 0, r1 = RS;
while(r1-l1 > 1){
int mid = (l1+r1)/2;
int x = mid, y = CS;
int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y);
if(!m.count({x, y})){
if(h == X){
Pinpoint(x, y);
g = true;
}
m[{x, y}] = h;
}
if(h < X) l1 = mid;
else r1 = mid;
}
int l2 = RS, r2 = R+1;
while(r2-l2 > 1){
int mid = (l2+r2)/2;
int x = mid, y = CS;
int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y);
if(!m.count({x, y})){
if(h == X){
Pinpoint(x, y);
g = true;
}
m[{x, y}] = h;
}
if(h < X) r2 = mid;
else l2 = mid;
}
auto f1 = [&](int x, int y, bool t = false){
x = r1+x;
y = CS-y;
if(t) return x*1000+y;
if(g) return 0;
int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y);
if(!m.count({x, y})){
if(h == X){
Pinpoint(x, y);
g = true;
}
m[{x, y}] = h;
}
return abs(h-X);
};
auto s1 = smawk(RS-r1+1, CS, f1);
for(int i = 0; i < s1.size(); i++){
cerr << s1[i] << " ";
f1(i, s1[i]);
}
cerr << endl;
auto f2 = [&](int x, int y, bool t = false){
x = r1+x;
y = CS+y;
if(t) return x*1000+y;
if(g) return 0;
int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y);
if(!m.count({x, y})){
if(h == X){
Pinpoint(x, y);
g = true;
}
m[{x, y}] = h;
}
return abs(h-X);
};
auto s2 = smawk(RS-r1+1, C-CS+1, f2);
for(int i = 0; i < s2.size(); i++){
cerr << s2[i] << " ";
f2(i, s2[i]);
}
cerr << endl;
auto f3 = [&](int x, int y, bool t = false){
x = l2-x;
y = CS-y;
if(t) return x*1000+y;
if(g) return 0;
int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y);
if(!m.count({x, y})){
if(h == X){
Pinpoint(x, y);
g = true;
}
m[{x, y}] = h;
}
return abs(h-X);
};
auto s3 = smawk(l2-RS+1, CS, f3);
for(int i = 0; i < s3.size(); i++){
cerr << s3[i] << " ";
f3(i, s3[i]);
}
cerr << endl;
auto f4 = [&](int x, int y, bool t = false){
x = l2-x;
y = CS+y;
if(t) return x*1000+y;
if(g) return 0;
int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y);
if(!m.count({x, y})){
if(h == X){
Pinpoint(x, y);
g = true;
}
m[{x, y}] = h;
}
return abs(h-X);
};
auto s4 = smawk(l2-RS+1, C-CS+1, f4);
for(int i = 0; i < s4.size(); i++){
cerr << s4[i] << " ";
f4(i, s4[i]);
}
cerr << endl;
}
詳細信息
answer.code:2:5: error: ‘pair’ was not declared in this scope 2 | map<pair<int, int>, int> m; | ^~~~ answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:5: error: ‘pair’ was not declared in this scope answer.code:2:1: error: ‘map’ does not name a type 2 | map<pair<int, int>, int> m; | ^~~ answer.code:4:1: error: ‘vector’ does not name a type 4 | vector<int> smawk(int h, int w, F f){ | ^~~~~~ answer.code: In function ‘void Rescue(int, int, int, int, int)’: answer.code:56:13: error: ‘m’ was not declared in this scope 56 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^ answer.code:56:43: error: ‘Measure’ was not declared in this scope 56 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^~~~~~~ answer.code:59:9: error: ‘Pinpoint’ was not declared in this scope 59 | Pinpoint(x, y); | ^~~~~~~~ answer.code:72:13: error: ‘m’ was not declared in this scope 72 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^ answer.code:72:43: error: ‘Measure’ was not declared in this scope 72 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^~~~~~~ answer.code:75:9: error: ‘Pinpoint’ was not declared in this scope 75 | Pinpoint(x, y); | ^~~~~~~~ answer.code: In lambda function: answer.code:88:13: error: ‘m’ was not declared in this scope 88 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^ answer.code:88:43: error: ‘Measure’ was not declared in this scope 88 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^~~~~~~ answer.code:91:9: error: ‘Pinpoint’ was not declared in this scope 91 | Pinpoint(x, y); | ^~~~~~~~ answer.code:96:12: error: ‘abs’ was not declared in this scope 96 | return abs(h-X); | ^~~ answer.code: In function ‘void Rescue(int, int, int, int, int)’: answer.code:98:13: error: ‘smawk’ was not declared in this scope 98 | auto s1 = smawk(RS-r1+1, CS, f1); | ^~~~~ answer.code:100:5: error: ‘cerr’ was not declared in this scope 100 | cerr << s1[i] << " "; | ^~~~ answer.code:103:3: error: ‘cerr’ was not declared in this scope 103 | cerr << endl; | ^~~~ answer.code:103:11: error: ‘endl’ was not declared in this scope 103 | cerr << endl; | ^~~~ answer.code: In lambda function: answer.code:109:13: error: ‘m’ was not declared in this scope 109 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^ answer.code:109:43: error: ‘Measure’ was not declared in this scope 109 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^~~~~~~ answer.code:112:9: error: ‘Pinpoint’ was not declared in this scope 112 | Pinpoint(x, y); | ^~~~~~~~ answer.code:117:12: error: ‘abs’ was not declared in this scope 117 | return abs(h-X); | ^~~ answer.code: In lambda function: answer.code:130:13: error: ‘m’ was not declared in this scope 130 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^ answer.code:130:43: error: ‘Measure’ was not declared in this scope 130 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^~~~~~~ answer.code:133:9: error: ‘Pinpoint’ was not declared in this scope 133 | Pinpoint(x, y); | ^~~~~~~~ answer.code:138:12: error: ‘abs’ was not declared in this scope 138 | return abs(h-X); | ^~~ answer.code: In lambda function: answer.code:151:13: error: ‘m’ was not declared in this scope 151 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^ answer.code:151:43: error: ‘Measure’ was not declared in this scope 151 | int h = m.count({x, y}) ? m[{x, y}] : Measure(x, y); | ^~~~~~~ answer.code:154:9: error: ‘Pinpoint’ was not declared in this scope 154 | Pinpoint(x, y); | ^~~~~~~~ answer.code:159:12: error: ‘abs’ was not declared in this scope 159 | return abs(h-X); | ^~~