답안 #1037497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1037497 2024-07-29T01:16:40 Z HappyCapybara 메기 농장 (IOI22_fish) C++17
0 / 100
289 ms 297288 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
int n;
vector<vector<int>> v;
unordered_map<ll,ll> m;
vector<vector<vector<ll>>> dp;
 
ll solve(int c, int p1, int p2){
  if (c == n) return 0;
  if (dp[c][p1][p2] != -1) return dp[c][p1][p2];
  ll cur = 0, res = 0;
  int l = 0, r = 0;
  while (r < v[c].size()){
    res = max((ll) res, (ll) cur+ (ll) solve(c+1, r, p1));
    //if (c == 3 && p1 == 2 && p2 == 0) cout << r << " " << res << "\n";
    while (c != 0 && l < p1 && v[c-1][l+1] <= v[c][r+1]){
      l++;
      cur -= m[(ll) c*100001ll + (ll) v[c-1][l]];
    }
    r++;
    if (c < n-1) cur += m[(ll) (c+1)*100001ll + (ll) v[c][r]];
    if (c > 0 && v[c-1][p1] < v[c][r] && (c == 1 || v[c][r] > v[c-2][p2])) cur += m[(ll) (c-1)*100001ll + (ll) v[c][r]];
  }
  //cout << c << " " << p1 << " " << p2 << " " << res << "\n";
  return dp[c][p1][p2] = res;
}
 
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
  n = N;
  v.resize(N, {-1});
  for (int i=0; i<M; i++){
    m[(ll)X[i]*100001ll+(ll)Y[i]] = W[i];
    if (X[i] > 0) v[X[i]-1].push_back(Y[i]);
    if (X[i] < N-1) v[X[i]+1].push_back(Y[i]);
  }
  for (int i=0; i<N; i++) sort(v[i].begin(), v[i].end());
  dp.resize(n, vector<vector<ll>>(10, vector<ll>(10, -1)));
  return solve(0, 0, 0);
}

Compilation message

fish.cpp: In function 'long long int solve(int, int, int)':
fish.cpp:17:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   while (r < v[c].size()){
      |          ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 223 ms 284096 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 289 ms 297288 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 150544 KB Output is correct
2 Correct 104 ms 150624 KB Output is correct
3 Incorrect 141 ms 137328 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '41647849438518'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 2 ms 604 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '431502134630'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 2 ms 604 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '431502134630'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 2 ms 604 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '431502134630'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 150544 KB Output is correct
2 Correct 104 ms 150624 KB Output is correct
3 Incorrect 141 ms 137328 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '41647849438518'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 223 ms 284096 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -