QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#125192 | #5439. Meet in the Middle | TadijaSebez | Compile Error | / | / | C++14 | 1.3kb | 2023-07-16 04:47:12 | 2023-07-16 04:47:14 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-16 04:47:14]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-16 04:47:12]
- 提交
answer
}
const int Q=500050;
vector<pair<int,int>> Qs[N];
ll ans[Q];
namespace Tree2{
vector<pair<int,int>> E[N];
int node[N],lid[N],rid[N],tid;
ll dep[N];
void AddEdge(int u,int v,int w){
E[u].pb({v,w});
E[v].pb({u,w});
}
void DFS(int u,int p){
lid[u]=++tid;
node[tid]=u;
for(auto e:E[u]){
int v=e.first;
if(v!=p){
dep[v]=dep[u]+e.second;
DFS(v,u);
}
}
rid[u]=tid;
}
void Solve(int u,int p){
for(auto q:Qs[u]){
ans[q.second]=::node[root].Query(q.first);
}
for(auto e:E[u]){
int v=e.first;
if(v!=p){
Add(root,1,tid,1,tid,e.second);
Add(root,1,tid,lid[v],rid[v],-2*e.second);
Solve(v,u);
Add(root,1,tid,1,tid,-e.second);
Add(root,1,tid,lid[v],rid[v],2*e.second);
}
}
}
void Solve(){
DFS(1,0);
Build(root,1,tid,node,dep);
Solve(1,0);
}
}
int main(){
int n,q;
scanf("%i %i",&n,&q);
for(int i=1;i<n;i++){
int u,v,w;
scanf("%i %i %i",&u,&v,&w);
Tree1::AddEdge(u,v,w);
}
for(int i=1;i<n;i++){
int u,v,w;
scanf("%i %i %i",&u,&v,&w);
Tree2::AddEdge(u,v,w);
}
for(int i=1;i<=q;i++){
int u,v;
scanf("%i %i",&u,&v);
Qs[v].push_back({u,i});
}
Tree1::Build();
Tree2::Solve();
for(int i=1;i<=q;i++){
printf("%lld\n",ans[i]);
}
return 0;
}
Details
answer.code:1:1: error: expected declaration before ‘}’ token 1 | } | ^ answer.code:4:1: error: ‘vector’ does not name a type 4 | vector<pair<int,int>> Qs[N]; | ^~~~~~ answer.code:5:1: error: ‘ll’ does not name a type 5 | ll ans[Q]; | ^~ answer.code:9:1: error: ‘vector’ does not name a type 9 | vector<pair<int,int>> E[N]; | ^~~~~~ answer.code:10:10: error: ‘N’ was not declared in this scope 10 | int node[N],lid[N],rid[N],tid; | ^ answer.code:10:17: error: ‘N’ was not declared in this scope 10 | int node[N],lid[N],rid[N],tid; | ^ answer.code:10:24: error: ‘N’ was not declared in this scope 10 | int node[N],lid[N],rid[N],tid; | ^ answer.code:11:1: error: ‘ll’ does not name a type 11 | ll dep[N]; | ^~ answer.code: In function ‘void Tree2::AddEdge(int, int, int)’: answer.code:14:9: error: ‘E’ was not declared in this scope 14 | E[u].pb({v,w}); | ^ answer.code: In function ‘void Tree2::DFS(int, int)’: answer.code:19:9: error: ‘lid’ was not declared in this scope; did you mean ‘tid’? 19 | lid[u]=++tid; | ^~~ | tid answer.code:20:9: error: ‘node’ was not declared in this scope 20 | node[tid]=u; | ^~~~ answer.code:21:20: error: ‘E’ was not declared in this scope 21 | for(auto e:E[u]){ | ^ answer.code:24:25: error: ‘dep’ was not declared in this scope 24 | dep[v]=dep[u]+e.second; | ^~~ answer.code:28:9: error: ‘rid’ was not declared in this scope; did you mean ‘tid’? 28 | rid[u]=tid; | ^~~ | tid answer.code: In function ‘void Tree2::Solve(int, int)’: answer.code:32:20: error: ‘Qs’ was not declared in this scope; did you mean ‘Q’? 32 | for(auto q:Qs[u]){ | ^~ | Q answer.code:33:17: error: ‘ans’ was not declared in this scope 33 | ans[q.second]=::node[root].Query(q.first); | ^~~ answer.code:33:33: error: ‘::node’ has not been declared 33 | ans[q.second]=::node[root].Query(q.first); | ^~~~ answer.code:33:38: error: ‘root’ was not declared in this scope 33 | ans[q.second]=::node[root].Query(q.first); | ^~~~ answer.code:35:20: error: ‘E’ was not declared in this scope 35 | for(auto e:E[u]){ | ^ answer.code:38:29: error: ‘root’ was not declared in this scope 38 | Add(root,1,tid,1,tid,e.second); | ^~~~ answer.code:38:25: error: ‘Add’ was not declared in this scope 38 | Add(root,1,tid,1,tid,e.second); | ^~~ answer.code:39:40: error: ‘lid’ was not declared in this scope; did you mean ‘tid’? 39 | Add(root,1,tid,lid[v],rid[v],-2*e.second); | ^~~ | tid answer.code:39:47: error: ‘rid’ was not declared in this scope; did you mean ‘tid’? 39 | Add(root,1,tid,lid[v],rid[v],-2*e.second); | ^~~ | tid answer.code: In function ‘void Tree2::Solve()’: answer.code:49:15: error: ‘root’ was not declared in this scope 49 | Build(root,1,tid,node,dep); | ^~~~ answer.code:49:26: error: ‘node’ was not declared in this scope 49 | Build(root,1,tid,node,dep); | ^~~~ answer.code:49:31: error: ‘dep’ was not declared in this scope 49 | Build(root,1,tid,node,dep); | ^~~ answer.code:49:9: error: ‘Build’ was not declared in this scope 49 | Build(root,1,tid,node,dep); | ^~~~~ answer.code: In function ‘int main()’: answer.code:57:9: error: ‘scanf’ was not declared in this scope 57 | scanf("%i %i",&n,&q); | ^~~~~ answer.code:61:17: error: ‘Tree1’ has not been declared 61 | Tree1::AddEdge(u,v,w); | ^~~~~ answer.code:71:17: error: ‘Qs’ was not declared in this scope; did you mean ‘Q’? 71 | Qs[v].push_back({u,i}); | ^~ | Q answer.code:73:9: error: ‘Tree1’ has not been declared 73 | Tree1::Build(); | ^~~~~ answer.code:76:33: error: ‘ans’ was not declared in this scope 76 | printf("%lld\n",ans[i]); | ^~~ answer.code:76:17: error: ‘printf’ was not declared in this scope 76 | printf("%lld\n",ans[i]); | ^~~~~~ answer.code:1:1: ...