제출 #1062215

#제출 시각아이디문제언어결과실행 시간메모리
1062215MarwenElarbi메기 농장 (IOI22_fish)C++17
0 / 100
955 ms2097152 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; #define pb push_back #define ll long long #define fi first #define se second long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { int n=N;int m=M; long long dp[n][n][2]; memset(dp,0,sizeof dp); long long grid[n][n]; memset(grid,0,sizeof grid); for (int i = 0; i < m; ++i) { grid[X[i]][Y[i]]=W[i]; } long long pre[n][n]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { pre[i][j]=(j ? pre[i][j-1] : 0)+grid[i][j]; } } long long ans=0; for (int i = 1; i < n; ++i) { for (int j = 0; j < n; ++j) { for (int k = 0; k < n; ++k) { if(k>j){ dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][k][0],dp[i-1][k][1])+pre[i][k]-(j>0 ? pre[i][j-1] : 0ll)); }else if(k<j){ dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]+pre[i-1][j]-(k>0 ? pre[i-1][k-1] : 0ll)); }else { dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]); dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][k][0],dp[i-1][k][1])); } dp[i][0][0]=max(dp[i][0][0],(dp[i-1][k][1],dp[i-1][j][0])); } ans=max(ans,dp[i][j][0]); ans=max(ans,dp[i][j][1]); } } return ans; }

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

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:42:50: warning: left operand of comma operator has no effect [-Wunused-value]
   42 |         dp[i][0][0]=max(dp[i][0][0],(dp[i-1][k][1],dp[i-1][j][0]));
      |                                      ~~~~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...