QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#45328 | #4561. Catfish Farm | keziaaurelia1 | 0 | 108ms | 670996kb | C++11 | 2.3kb | 2022-08-22 17:26:56 | 2022-08-22 17:26:59 |
Judging History
answer
#include "fish.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define ss se.se
#define fs fi.se
#define sf se.fi
#define all(x) x.begin(), x.end()
#define endl "\n"
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MX=3e5+5;
ll ans[305][305][305][3];
ll n;
ll val[305][305];
ll pref[305][305];
//nw 0 menaik 1 menurun
//awal 0 artinya pertama
//awal 1 artinya diambil depannya
ll dp(int idx, int st, int nw,int awal){
if(idx>=n || st>n || st<0)return 0;
if(ans[idx][st][nw][awal]!=-1)return ans[idx][st][nw][awal];
ll tmp=0;
ll tambah=0;
tmp=max(tmp, dp(idx+2, 0,0,1)+pref[idx+1][st]);
if(nw==0){
// lagi fase menaik
//tambahin satu blok
tambah=0;
if(awal==1)tambah=val[idx-1][st+1];
tmp=max(tmp,dp(idx, st+1,nw,awal)+tambah);
//pindah kolom
tmp=max(tmp, dp(idx+1, st, nw,1));
//pindah kolom dan arah
tmp=max(tmp, dp(idx+1, st,1,1));
}
else{
//lagi fase menurun
//turunin 1 blok
tmp=max(tmp,dp(idx, st-1,nw,1)+val[idx][st]);
//pindah kolom
tmp=max(tmp, dp(idx+1, st,nw,1));
}
tmp=max(tmp, dp(idx+2, st,0,1)+pref[idx+1][st]);
//kalo nextnya lebih pendek
tmp=max(tmp, dp(idx+2, 0,0,0)+pref[idx+1][st]);
// cerr<<"ans ["<<idx<<"]["<<st<<"]["<<nw<<"]["<<awal<<"] = "<<tmp<<endl;
ans[idx][st][nw][awal]=tmp;
return ans[idx][st][nw][awal];
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
memset(ans,-1, sizeof(ans));
n=N;
if(N>300)return 0;
for(int i=0;i<M;i++){
val[X[i]+1][Y[i]+1]=W[i];
}
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
pref[i][j]=pref[i][j-1]+val[i][j];
}
}
return dp(1,0,0,0);
}
//vector<int> arr1,arr2,arr3;
//int main(){
// arr1.pb(1);
// arr1.pb(3);
// arr2.pb(10);
// arr2.pb(2);
// arr3.pb(6);
// arr3.pb(7);
// cout<<max_weights(11, 2,arr1,arr2,arr3)<<endl;
//// for(int i=0;i<15;i++){
//// for(int j=0;j<=15;j++){
//// cerr<<"pref "<<i<<" "<<j<<" = "<<pref[i][j]<<endl;
//// }
//// }
// return 0;
//}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 94ms
memory: 670996kb
input:
f785163bfcb92ce6ac387bba5d2f29a0e0f37f19 90000 80699 0 10792 55091480 0 36762 389250726 0 79267 706445371 0 76952 290301137 0 13444 69711795 0 68980 66221400 0 1695 703252611 0 36628 632571604 0 87676 264578012 0 79496 397448339 0 57929 447544332 0 35453 355374818 0 62449 686423696 0 45614 667165709...
output:
938f2698235a9ff1d1d91e23381b68bec7bed102 OK 0
result:
wrong answer 3rd lines differ - expected: '40313272768926', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 91ms
memory: 669000kb
input:
f785163bfcb92ce6ac387bba5d2f29a0e0f37f19 3 2 0 0 1 1 1 1
output:
938f2698235a9ff1d1d91e23381b68bec7bed102 OK 1
result:
wrong answer 3rd lines differ - expected: '2', found: '1'
Subtask #3:
score: 0
Wrong Answer
Test #20:
score: 0
Wrong Answer
time: 100ms
memory: 669808kb
input:
f785163bfcb92ce6ac387bba5d2f29a0e0f37f19 100000 1 0 0 10082010
output:
938f2698235a9ff1d1d91e23381b68bec7bed102 OK 0
result:
wrong answer 3rd lines differ - expected: '10082010', found: '0'
Subtask #4:
score: 0
Wrong Answer
Test #28:
score: 0
Wrong Answer
time: 88ms
memory: 669812kb
input:
f785163bfcb92ce6ac387bba5d2f29a0e0f37f19 4 3 2 2 1 0 0 1 1 1 1
output:
938f2698235a9ff1d1d91e23381b68bec7bed102 OK 2
result:
wrong answer 3rd lines differ - expected: '3', found: '2'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Wrong Answer
Test #60:
score: 0
Wrong Answer
time: 108ms
memory: 670688kb
input:
f785163bfcb92ce6ac387bba5d2f29a0e0f37f19 100000 99999 31026 31026 1 42940 42940 1 69303 69303 1 90350 90350 1 77507 77507 1 87126 87126 1 17988 17988 1 5146 5146 1 63023 63023 1 27776 27776 1 6136 6136 1 82557 82557 1 24904 24904 1 21667 21667 1 67271 67271 1 80294 80294 1 81145 81145 1 47144 47144 ...
output:
938f2698235a9ff1d1d91e23381b68bec7bed102 OK 0
result:
wrong answer 3rd lines differ - expected: '99999', found: '0'
Subtask #8:
score: 0
Skipped
Dependency #1:
0%