Submission #682515

#TimeUsernameProblemLanguageResultExecution timeMemory
682515vjudge1Building 4 (JOI20_building4)C++17
11 / 100
893 ms178176 KiB
#include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") using namespace std; #define int long long #define ll long long #define vi vector<long long> #define pb push_back #define sz(s) (int)s.size() #define all(v) v.begin(), v.end() #define show(a) cerr << #a <<" -> "<< a <<"\n" #define pp pair<int,int> #define FF first #define SS second #define endl "\n" #define ld long double const int N = 1e6 + 2, N3 = 1e3 + 6, inf = 1e18 + 7, LOG = 20; map<char, int> md{{'N', 0}, {'E', 1}, {'S', 2}, {'W', 3}}; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; string stepDir = "RDLU"; int n, a[N], b[N], dp[4001][2001], col[4001][2001]; main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); cin >> n; for (int i = 1; i <= n * 2; i++) { cin >> a[i]; } for (int i = 1; i <= n * 2; i++) { cin >> b[i]; } for (int i = 0; i <= n * 2; i++) { for (int j = 0; j <= n; j++) { dp[i][j] = inf; } } dp[0][0] = 0; for (int i = 1; i <= n * 2; i++) { for (int j = 0; j <= min(i, n); j++) { if (j != 0 && a[i] >= dp[i - 1][j - 1]) { dp[i][j] = a[i]; col[i][j] = 1; } if (b[i] >= dp[i - 1][j] && b[i] < dp[i][j]) { dp[i][j] = b[i]; col[i][j] = 2; } } } vi v; int i = n * 2, j = n; while (i > 0) { if (dp[i][j] == inf) { cout << -1; return 0; } v.pb(col[i][j]); if (col[i][j] == 1) { j--; } i--; } reverse(all(v)); for (auto to : v) { if (to == 1) cout << "A"; else cout << "B"; } return 0; }

Compilation message (stderr)

building4.cpp:3: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    3 | #pragma comment(linker, "/stack:200000000")
      | 
building4.cpp:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...