답안 #657522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657522 2022-11-10T02:30:03 Z sentheta 메기 농장 (IOI22_fish) C++17
0 / 100
56 ms 17312 KB
#include "fish.h"
// author : sentheta aka vanwij
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<random>
#include<chrono>
#include<cmath>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;

#define Int long long
#define V vector
#define pii pair<int,int>
#define ff first
#define ss second

#define rand() (uniform_int_distribution<int>(0,1<<30)(rng))
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pow2(x) (1LL<<(x))
#define msb(x) (63-__builtin_clzll(x))
#define bitcnt(x) (__builtin_popcountll(x))

#define nl '\n'
#define _ << ' ' <<
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define dbg(x) if(1) cout << "?" << #x << " : " << (x) << endl << flush;

const Int N = 305;

Int n, m;
V<Int> x, y, w;

// V<pii> g[N];
Int g[N][N];
Int sum(Int i,Int l,Int r){
	Int ret = g[i][r];
	if(l>0) ret -= g[i][l-1];
	return ret;
}

Int dp[N][N][2];

Int max_weights(int _n,int _m,V<int> _x,V<int> _y,V<int> _w){
	n = _n; m = _m;
	x = V<Int>(all(_x)); y = V<Int>(all(_y)); w = V<Int>(all(_w));

	rep(i,0,m){
		// dbg(x[i]);
		// g[x[i]].push_back({y[i], w[i]});
		
		g[x[i]][y[i]] = w[i];
	}
	rep(i,0,n){
		// dbg(i);
		// sort(all(g[i]));
		// g[i].push_back({n, 0});
		// for(auto[j,k] : g[i]) cout << j _ k << nl;

		rep(j,1,n){
			g[i][j] += g[i][j-1];
		}
	}
	// cout << nl;

	rep(i,1,n){
		// dbg(i);

		// 0 = increasing, 1 = decreasing
		rep(q,0,n) rep(dir,0,2) rep(r,0,n){
			Int cost = dp[i-1][q][dir];

			// coverage of pier, stop right before the q-th fish
			int qq = q-1;
			int rr = r-1;
			// dbg(pp); dbg(qq); dbg(rr);

			// rep(j,q,g[i-1].size())
			// if(pp<g[i-1][j].ff && g[i-1][j].ff<=rr){
			// 	cost += g[i-1][j].ss;
			// }
			if(dir==0 && qq<rr){
				cost += sum(i-1, qq+1, rr);
			}

			// rep(j,r,g[i].size()) if(g[i][j].ff <= qq-1){
			// 	cost += g[i][j].ss;
			// }
			if(dir==1 && qq>rr){
				cost += sum(i, rr+1, qq);
			}

			// dbg(cost);
			// cout << nl;

			// change direction
			if(rr==-1){
				dp[i][r][0] = max(dp[i][r][0], cost);
			}

			if(dir==0 && qq <= rr){
				dp[i][r][0] = max(dp[i][r][0], cost);
			}
			if(dir==1 && qq >= rr){
				dp[i][r][1] = max(dp[i][r][1], cost);
			}
			// dp[i][q][r] = max(dp[i][q][r], cost);
		}
	}

	// dbg(dp[1][0][0]);
	// dbg(dp[1][0][1]);
	// dbg(dp[1][1][0]);
	// dbg(dp[1][1][1]);

	Int ans = 0;
	rep(p,0,n) rep(q,0,n){
		ans = max(ans, dp[n-1][p][q]);
	}
	return ans;




	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 9568 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Runtime error 56 ms 17312 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 9568 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -