Submission #740464

# Submission time Handle Problem Language Result Execution time Memory
740464 2023-05-12T13:55:06 Z tolbi Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 2097152 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& in, pair<X,Y> &pr) {return in>>pr.first>>pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr) {return os<<pr.first<<" "<<pr.second;}
template<typename X, typename Y> pair<X,Y> operator+(pair<X,Y> a, pair<X,Y> b) {pair<X,Y> c; c.first=a.first+b.first,c.second=a.second+b.second;return c;}
template<typename X, typename Y> pair<X,Y> operator-(pair<X,Y> a, pair<X,Y> b) {pair<X,Y> c; c.first=a.first-b.first,c.second=a.second-b.second;return c;}
template<typename X, typename Y> void operator+=(pair<X,Y> &a, pair<X,Y> b){a.first+=b.first,a.second+=b.second;}
template<typename X, typename Y> void operator-=(pair<X,Y> &a, pair<X,Y> b){a.first-=b.first,a.second-=b.second;}
template<typename X> istream& operator>>(istream& in, vector<X> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X> ostream& operator<<(ostream& os, vector<X> arr) {for(auto &it : arr) os<<it<<" "; return os;}
template<typename X, size_t Y> istream& operator>>(istream& in, array<X,Y> &arr) {for(auto &it : arr) in>>it; return in;}
template<typename X, size_t Y> ostream& operator<<(ostream& os, array<X,Y> arr) {for(auto &it : arr) os<<it<<" "; return os;}
#define int long long
#define endl '\n'
#define vint(x) vector<int> x
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(),x.end())
#define sortrarr(x) sort(x.rbegin(),x.rend())
#define det(x) cout<<"NO\0YES"+x*3<<endl;
#define INF LONG_LONG_MAX
#define rev(x) reverse(x.begin(),x.end());
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define tol(bi) (1LL<<((int)(bi)))
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
vector<vector<vector<int>>> dp;
vector<vector<int>> we;
int n;
int f(int x, int lel1, int lel2){
	if (x==n) {
		int ans = 0ll;
		for (int i = lel2+1; i <= lel1; i++){
			ans+=we[x-1][i];
		}
		return ans;
	}
	if (dp[x][lel1][lel2]!=-1) return dp[x][lel1][lel2];
	int ans = 0ll;
	for (int i = 0; i <= n; i++){
		int crcr = 0ll;
		for (int j = lel2+1; j <= max(i,lel1); j++){
			crcr+=we[x-1][j];
		}
		ans=max(ans,crcr+f(x+1,lel2,i));
	}
	return dp[x][lel1][lel2]=ans;
}
long long max_weights(int32_t nn, int32_t m, vector<int32_t> x, vector<int32_t> y, vector<int32_t> w) {
	n=nn;
	dp.resize(n+1,vector<vector<int>>(n+1,vector<int>(n+1,-1)));
	we.resize(n+1,vector<int>(n+1,0));
	for (int i = 0; i < m; i++){
		we[x[i]][y[i]+1]=w[i];
	}
	int ans = 0ll;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= n; j++){
			int crr = 0ll;
			for (int z = i+1; z <= j; z++){
				crr+=we[0][z];
			}
			ans=max(ans,crr+f(2,i,j));
		}
	}
	return ans;
}




#ifdef tolbi
int32_t main(){
	ios;
	int t=1;
	int tno = 0;
	if (!t) cin>>t;
	while (t-(tno++)){
		int32_t n,m;cin>>n>>m;
		vector<int32_t> x(m),y(m),z(m);
		for (int i = 0; i < m; i++){
			cin>>x[i]>>y[i]>>z[i];
		}
		cout<<max_weights(n,m,x,y,z)<<endl;
	}
}
#endif

Compilation message

fish.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
# Verdict Execution time Memory Grader output
1 Execution timed out 1118 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 216 KB Output is correct
2 Runtime error 868 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 753 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Execution timed out 1085 ms 28080 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Execution timed out 1085 ms 28080 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Execution timed out 1085 ms 28080 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 753 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1118 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -