# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528880 | ajpiano | Building 4 (JOI20_building4) | C++17 | 609 ms | 524292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
typedef pair<int,int> pi;
const int large = 1e5+5;
bitset<large/2> dp[large][2];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<int> a(2*n), b(2*n);
for(int i = 0; i < 2*n; i++) cin >> a[i];
for(int i = 0; i < 2*n; i++) cin >> b[i];
dp[0][0][0] = 1;
dp[0][1][1] = 1;
for(int i = 1; i < 2*n; i++){
if(a[i-1] <= a[i]) dp[i][0] = dp[i-1][0];
if(b[i-1] <= b[i]) dp[i][1] = dp[i-1][1]<<1;
if(b[i-1] <= a[i]) dp[i][0] |= dp[i-1][1];
if(a[i-1] <= b[i]) dp[i][1] |= dp[i-1][0]<<1;
}
if(dp[2*n-1][0][n]|dp[2*n-1][1][n]){
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |