답안 #1069319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069319 2024-08-21T19:28:20 Z beaconmc 메기 농장 (IOI22_fish) C++17
9 / 100
417 ms 101620 KB
#include "fish.h"

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)

const ll maxn = 100005;


set<ll> fish[maxn];

map<vector<ll>, ll> weights;

ll dp[7][7][maxn];

set<ll> temppos[maxn];
vector<ll> possibles[maxn];

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    FOR(i,0,7){
        FOR(j,0,7){
            FOR(k,0,maxn){
                dp[i][j][k] = 0;
            }
        }
    }
    FOR(i,0,maxn) temppos[i].insert(0);


    FOR(i,0,M){
        Y[i]++;
        fish[X[i]].insert(Y[i]);
        weights[{X[i], Y[i]}] = W[i];
        if (X[i] > 0) temppos[X[i]-1].insert(Y[i]);
        temppos[X[i]+1].insert(Y[i]);
        temppos[X[i]].insert(Y[i]);
    }
    FOR(i,0,maxn){
        for (auto&k : temppos[i]) possibles[i].push_back(k);
    }

    FOR(k,0,N){
        FOR(X,0,7){
            FOR(Y,0,7){
                ll i=0,j=0;
 
                if (k>=2 && possibles[k-2].size() <= X) continue;
                else if (k>=2) i = possibles[k-2][X];
                if (k>=1 && possibles[k-1].size() <= Y) continue;
                else if (k>=1) j  = possibles[k-1][Y];
                


                ll temp = 0;
                FOR(Z, 0, 7){
                    if (possibles[k].size() <= Z) continue;
                    ll height = possibles[k][Z];

                    if (fish[k+1].count(height)) temp += weights[{k+1, height}];

                    if (fish[k].count(height) && j>=height) temp -= weights[{k, height}];

                    if (k>0 && fish[k-1].count(height) && i < height && j<height) temp += weights[{k-1, height}];

                    dp[Y][Z][k+1] = max(dp[Y][Z][k+1], dp[X][Y][k] + temp);
                }
            }
        }
    }




    ll ans = 0;
    FOR(i,0,7){
        FOR(j,0,7){
            FOR(k,0,N+1){
                ans = max(ans, dp[i][j][k]);
                if (dp[i][j][k]==11) cout << i << " " << j << " " << k << endl;

            }
        }
    }
    return ans;





}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:51:51: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   51 |                 if (k>=2 && possibles[k-2].size() <= X) continue;
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~
fish.cpp:53:51: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   53 |                 if (k>=1 && possibles[k-1].size() <= Y) continue;
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~
fish.cpp:60:45: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   60 |                     if (possibles[k].size() <= Z) continue;
      |                         ~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 81476 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '2335128467'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 58200 KB Output is correct
2 Incorrect 357 ms 101620 KB 1st lines differ - on the 1st token, expected: '40604614618209', found: '4174181155'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 58156 KB Output is correct
2 Correct 38 ms 58340 KB Output is correct
3 Correct 120 ms 70740 KB Output is correct
4 Correct 91 ms 67344 KB Output is correct
5 Correct 207 ms 82512 KB Output is correct
6 Correct 215 ms 81972 KB Output is correct
7 Correct 241 ms 82452 KB Output is correct
8 Correct 233 ms 82516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 58204 KB Output is correct
2 Correct 26 ms 58204 KB Output is correct
3 Correct 27 ms 58200 KB Output is correct
4 Correct 31 ms 58324 KB Output is correct
5 Correct 27 ms 58204 KB Output is correct
6 Correct 27 ms 58204 KB Output is correct
7 Correct 29 ms 58204 KB Output is correct
8 Correct 29 ms 58204 KB Output is correct
9 Correct 29 ms 58460 KB Output is correct
10 Incorrect 38 ms 58708 KB 1st lines differ - on the 1st token, expected: '799839985182', found: '600368015531'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 58204 KB Output is correct
2 Correct 26 ms 58204 KB Output is correct
3 Correct 27 ms 58200 KB Output is correct
4 Correct 31 ms 58324 KB Output is correct
5 Correct 27 ms 58204 KB Output is correct
6 Correct 27 ms 58204 KB Output is correct
7 Correct 29 ms 58204 KB Output is correct
8 Correct 29 ms 58204 KB Output is correct
9 Correct 29 ms 58460 KB Output is correct
10 Incorrect 38 ms 58708 KB 1st lines differ - on the 1st token, expected: '799839985182', found: '600368015531'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 58204 KB Output is correct
2 Correct 26 ms 58204 KB Output is correct
3 Correct 27 ms 58200 KB Output is correct
4 Correct 31 ms 58324 KB Output is correct
5 Correct 27 ms 58204 KB Output is correct
6 Correct 27 ms 58204 KB Output is correct
7 Correct 29 ms 58204 KB Output is correct
8 Correct 29 ms 58204 KB Output is correct
9 Correct 29 ms 58460 KB Output is correct
10 Incorrect 38 ms 58708 KB 1st lines differ - on the 1st token, expected: '799839985182', found: '600368015531'
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 58156 KB Output is correct
2 Correct 38 ms 58340 KB Output is correct
3 Correct 120 ms 70740 KB Output is correct
4 Correct 91 ms 67344 KB Output is correct
5 Correct 207 ms 82512 KB Output is correct
6 Correct 215 ms 81972 KB Output is correct
7 Correct 241 ms 82452 KB Output is correct
8 Correct 233 ms 82516 KB Output is correct
9 Incorrect 417 ms 93268 KB Possible tampering with the output
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 81476 KB 1st lines differ - on the 1st token, expected: '40313272768926', found: '2335128467'
2 Halted 0 ms 0 KB -