QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#877028 | #9678. 网友小 Z 的树 | ereoth | Compile Error | / | / | C++14 | 1.5kb | 2025-01-31 18:27:43 | 2025-01-31 18:27:43 |
Judging History
This is the latest submission verdict.
- [2025-01-31 18:27:43]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-01-31 18:27:43]
- Submitted
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include "diameter.h"
using namespace std;
using Pii = pair<int, int>;
const long long kB = 2e5 + 3;
int n, m;
map<long long, int> hsh;
int Query(int x, int y, int z) {
if(x > y) swap(x, y);
if(y > z) swap(y, z);
if(x > y) swap(x, y);
long long h = kB * kB * x + kB * y + z;
if(mp.count(h)) {
return mp[h];
}
return mp[h] = query(x, y, z);
}
Pii find_diameter(int task_id, int n) {
mp.clear();
if (n <= 2) return {1, n};
int x = 1, y = 2, z = 3;
for(int i = 1; i <= n; i++) {
if(i == x || i == y || i == z) continue;
if(Query(x, y, z) < Query(i, y, z)) x = i;
}
for(int i = 1; i <= n; i++) {
if(i == x || i == y || i == z) continue;
if(Query(x, y, z) < Query(x, i, z)) y = i;
}
for(int i = 1; i <= n; i++) {
if(i == x || i == y || i == z) continue;
if(Query(x, y, z) < Query(x, y, i)) z = i;
}
int v = 0;
for(int i = 1; i <= n; i++) {
if(i == x || i == y || i == z) continue;
if(!v || Query(x, y, i) < Query(x, y, v)) v = i;
}
if(!v) {
if(in(x, y, z)) return {y, z};
if(in(y, x, z)) return {x, z};
return {x, y};
}
if(in(x, y, v)) return {y, z};
if(in(v, x, z)) swap(x, y);
int a = Query(x, y, v) / 2, b = Query(y, z, v) / 2, c = Query(x, y, z) - a - b;
if(max({a, b, c}) == a) return {x, y};
if(max({a, b, c}) == b) return {y, z};
return {x, z};
}
Details
answer.code: In function ‘int Query(int, int, int)’: answer.code:22:6: error: ‘mp’ was not declared in this scope; did you mean ‘m’? 22 | if(mp.count(h)) { | ^~ | m answer.code:25:10: error: ‘mp’ was not declared in this scope; did you mean ‘m’? 25 | return mp[h] = query(x, y, z); | ^~ | m answer.code: In function ‘Pii find_diameter(int, int)’: answer.code:29:3: error: ‘mp’ was not declared in this scope; did you mean ‘m’? 29 | mp.clear(); | ^~ | m