제출 #503046

#제출 시각아이디문제언어결과실행 시간메모리
503046ismoilovBiochips (IZhO12_biochips)C++14
100 / 100
268 ms402372 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++) #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--) #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--) const int maxx = 2e5+5; int a[maxx], b[maxx]; int d[maxx][505]; vector <int> g[maxx]; int n, m, r, cnt = 0; void dfs(int v){ b[v] = cnt; for(auto it : g[v]) dfs(it); fpp(i,1,m) d[cnt+1][i] = max(d[cnt][i], d[b[v]][i - 1] + a[v]); cnt ++; } void S() { cin >> n >> m; fpp(i,1,n){ int x; cin >> x >> a[i]; if(x == 0) r = i; else g[x].push_back(i); } fpp(i,1,m) d[0][i] = -maxx; dfs(r); cout << d[n][m]; } int main() { IOS; S(); }

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

biochips.cpp: In function 'void dfs(int)':
biochips.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
biochips.cpp:19:2: note: in expansion of macro 'fpp'
   19 |  fpp(i,1,m)
      |  ^~~
biochips.cpp: In function 'void S()':
biochips.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
biochips.cpp:27:2: note: in expansion of macro 'fpp'
   27 |  fpp(i,1,n){
      |  ^~~
biochips.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
biochips.cpp:35:2: note: in expansion of macro 'fpp'
   35 |  fpp(i,1,m)
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...