Submission #931015

# Submission time Handle Problem Language Result Execution time Memory
931015 2024-02-21T05:32:26 Z vjudge1 Building 4 (JOI20_building4) C++17
0 / 100
246 ms 524288 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)v.size()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 1e18;
const int mod = 1e9 + 7;
const int N = 305;
int dis[N][N], val[N][N];

void solve(){
	int n; cin >> n;
	vector<int> a(2 * n + 1), b(2 * n + 1);
	for(int i = 1; i <= 2 * n; i++) cin >> a[i];
	for(int i = 1; i <= 2 * n; i++) cin >> b[i];
	
	vector<vector<int> > dp(2 * n + 1, vector<int>(2 * n + 1));
	vector<vector<string> > dps(2 * n + 1, vector<string>(2 * n + 1));
	dp[0][0] = 1;
	dps[0][0] = "";
	for(int i = 1; i <= 2 * n; i++){
		for(int j = 0; j <= i; j++){
			if(j != 0 and dp[i - 1][j - 1] != 0 and dp[i - 1][j - 1] <= a[i]) dp[i][j] = a[i], dps[i][j] = dps[i - 1][j - 1] + 'A';
			if(dp[i - 1][j] != 0 and dp[i - 1][j] <= b[i]){
				if((dp[i][j] == 0 ? INF : dp[i][j]) >= b[i]){
					dp[i][j] = b[i];
					dps[i][j] = dps[i - 1][j] + 'B';
				}
			}
		}
	}
	
	cout << (dp[2 * n][n] == 0 ? "-1" : dps[2 * n][n]);
}

main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
}

Compilation message

building4.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 Runtime error 246 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 Runtime error 246 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -