# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900691 | stefanneagu | Building 4 (JOI20_building4) | C++17 | 4 ms | 8796 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.
// ce mai de cacat scoala : Un respectabil domn profesor de la scoala pe care o iubeste insane de mult metehau suge pula
#include <bits/stdc++.h>
#warning Un respectabil domn profesor de la scoala pe care o iubeste metehau suge pula
using namespace std;
const int nmax = 1e6 + 1;
int mat[nmax][2], ma[nmax][2], mi[nmax][2];
int main() {
int n;
cin >> n;
for(int i = 0; i < 2; i ++) {
for(int j = 0; j < 2 * n; j ++) {
cin >> mat[j][i];
}
}
mi[0][1] = 1, ma[0][1] = 1;
for(int i = 1; i < 2 * n; i ++) {
for(int j = 0; j < 2; j ++) {
mi[i][j] = 1e9, ma[i][j] = -1e9;
for(int k = 0; k < 2; k ++) {
if(mi[i - 1][k] <= ma[i - 1][k] && mat[i][j] >= mat[i - 1][k]) {
mi[i][j] = min(mi[i][j], mi[i - 1][k] + j);
ma[i][j] = max(ma[i][j], ma[i - 1][k] + j);
}
//cout << mi[i][j] << " " << ma[i][j] << endl;
}
}
}
int j;
if(mi[2 * n - 1][0] <= n && n <= ma[2 * n - 1][0]) {
j = 0;
} else if(mi[2 * n - 1][1] <= n && n <= ma[2 * n - 1][1]) {
j = 1;
} else {
cout << "-1";
assert("pula" == "lunga");
return 0; // as avea tupeu sa bag numele dar mihnea = stalker nasol + paracios
cout << "Un respectabil domn profesor de la scoala pe care o iubeste metehau suge pula";
}
string ans = "";
for(int i = 2 * n - 1; i >= 0;) {
if(j) {
ans += 'B';
} else {
ans += 'A';
}
n -= j;
i --;
if(mi[i][1] <= n && n <= ma[i][1] && mat[i][1] <= mat[i + 1][1]) {
j = 1;
} else {
j = 0;
}
}
reverse(ans.begin(), ans.end());
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |