| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1284813 | SmuggingSpun | Passport (JOI23_passport) | C++20 | 7 ms | 580 KiB |
#include<bits/stdc++.h>
#define taskname "C"
typedef long long ll;
using namespace std;
template<class T>void minimize(T& a, T b){
if(a > b){
a = b;
}
}
const int INF = 1e9;
int n, q;
namespace sub2{
void solve(){
vector<int>L(n + 1), R(n + 1);
for(int i = 1; i <= n; i++){
cin >> L[i] >> R[i];
}
vector<vector<int>>dp(n + 1, vector<int>(n + 1, INF));
dp[1][n] = 0;
for(int len = n - 2; len > -1; len--){
for(int l = 1; true; l++){
int r = l + len;
if(r > n){
break;
}
for(int i = l; i <= r; i++){
minimize(dp[l][r], dp[min(L[i], l)][max(R[i], r)] + 1);
}
}
}
cin >> q;
for(int _ = 0; _ < q; _++){
int x;
cin >> x;
cout << (dp[x][x] == INF ? -1 : dp[x][x]) << "\n";
}
}
}
namespace sub1345{
void solve(){
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n;
if(n <= 300){
sub2::solve();
}
else{
sub1345::solve();
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
