Submission #40443

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
404432018-02-01 13:11:19szawinisBirthday gift (IZhO18_treearray)C++14
100 / 100
2045 ms105188 KiB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
using namespace std;
const int N = 1 << 18;
int n, m, q, a[N];
vector<int> g[N];
set<int> pos[N], lca_pos[N];
int d[N];
vector<int> anc[N];
void dfs(int u, int p) {
for(int v: g[u]) if(v != p) {
d[v] = d[u] + 1;
anc[v].push_back(u);
for(int j = 0; 1 << j+1 <= d[v]; j++)
anc[v].push_back(anc[anc[v][j]][j]);
dfs(v, u);
}
}
int lca(int u, int v) {
if(d[v] > d[u]) swap(u, v);
if(d[u] > d[v]) {
for(int j = 0; 1 << j <= d[u] - d[v]; j++)
if(d[u] - d[v] >> j & 1) u = anc[u][j];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

treearray.cpp: In function 'void dfs(int, int)':
treearray.cpp:21:24: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   for(int j = 0; 1 << j+1 <= d[v]; j++)
                        ^
treearray.cpp: In function 'int lca(int, int)':
treearray.cpp:30:12: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
    if(d[u] - d[v] >> j & 1) u = anc[u][j];
            ^
treearray.cpp:34:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(j < anc[u].size() && anc[u][j] != anc[v][j])
        ^
treearray.cpp: In function 'int main()':
treearray.cpp:40:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &m, &q);
                               ^
treearray.cpp:42:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &u, &v);
                         ^
treearray.cpp:48:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+i);
                   ^
treearray.cpp:53:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &tp);
                   ^
treearray.cpp:55:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d", &i, &v);
                          ^
treearray.cpp:64:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d %d", &l, &r, &v);
                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...