Submission #931022

#TimeUsernameProblemLanguageResultExecution timeMemory
931022vjudge1Building 4 (JOI20_building4)C++17
0 / 100
226 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #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() const int INF = 1e18; const int mod = 1e9 + 7; const int N = 305; 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, 0)); 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 or 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 (stderr)

building4.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...