제출 #90280

#제출 시각아이디문제언어결과실행 시간메모리
90280psmaoDeblo (COCI18_deblo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fo(i,s,t) for(int i = s; i <= t; ++ i) #define fd(i,s,t) for(int i = s; i >= t; -- i) #define sf scanf #define pf printf typedef long long ll; const int maxn = 100050; int n, a[maxn], g[maxn][30][2]; ll ret[30][2], ans, sz[30][2]; VI adj[maxn]; void dfs(int u, int fa=0) { for(auto p : adj[u]) if(p != fa) dfs(p, u); fo(j,0,29) ret[j][0] = ret[j][1] = sz[j][0] = sz[j][1] = 0; fo(j,0,29) if(a[u]&(1<<j)) g[u][j][1] = 1; else g[u][j][0] = 1; for(auto p : adj[u]) if(p != fa) { fo(j,0,29) { if(a[u]&(1<<j)) g[u][j][0] += g[p][j][1], g[u][j][1] += g[p][j][0]; else g[u][j][0] += g[p][j][0], g[u][j][1] += g[p][j][1]; ret[j][0] += sz[j][0] * g[p][j][0] + sz[j][1] * g[p][j][1]; ret[j][1] += sz[j][1] * g[p][j][0] + sz[j][0] * g[p][j][1]; sz[j][0] += g[p][j][0]; sz[j][1] += g[p][j][1]; } } fo(i,0,29) ret[i][0] += sz[i][0], ret[i][1] += sz[i][1]; fo(i,0,29) if(a[u]&(1<<i)) ans += (1<<i)*ret[i][0]; else ans += (1<<i)*ret[i][1]; ans += a[u]; } int main() { sf("%d",&n); fo(i,1,n) sf("%d",&a[i]); fo(i,2,n) {int u, v; sf("%d%d",&u,&v); adj[u].emplace_back(v); adj[v].emplace_back(u);} dfs(1); cout << ans << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

deblo.cpp:11:1: error: 'VI' does not name a type
 VI adj[maxn];
 ^~
deblo.cpp: In function 'void dfs(int, int)':
deblo.cpp:14:15: error: 'adj' was not declared in this scope
  for(auto p : adj[u]) if(p != fa) dfs(p, u);
               ^~~
deblo.cpp:17:15: error: 'adj' was not declared in this scope
  for(auto p : adj[u]) if(p != fa)
               ^~~
deblo.cpp: In function 'int main()':
deblo.cpp:36:41: error: 'adj' was not declared in this scope
  fo(i,2,n) {int u, v; sf("%d%d",&u,&v); adj[u].emplace_back(v); adj[v].emplace_back(u);}
                                         ^~~
deblo.cpp:34:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d",&n);
    ^
deblo.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fo(i,1,n) sf("%d",&a[i]);
              ^
deblo.cpp:36:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fo(i,2,n) {int u, v; sf("%d%d",&u,&v); adj[u].emplace_back(v); adj[v].emplace_back(u);}
                         ^