Submission #931017

#TimeUsernameProblemLanguageResultExecution timeMemory
931017vjudge1Building 4 (JOI20_building4)C++17
0 / 100
241 ms524288 KiB
#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 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:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...