Submission #991000

#TimeUsernameProblemLanguageResultExecution timeMemory
991000PacybwoahPassport (JOI23_passport)C++17
16 / 100
2067 ms1048576 KiB
#include<iostream> #include<vector> #include<utility> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<pair<int, int>> vec(n + 1); for(int i = 1; i <= n; i++) cin >> vec[i].first >> vec[i].second; vector<vector<int>> dp(n + 1, vector<int>(n + 1, 1e9)); dp[1][n] = 0; for(int l = n - 1; l > 0; l--){ for(int i = 1; i + l - 1 <= n; i++){ int j = i + l - 1; for(int k = i; k <= j; k++){ dp[i][j] = min(dp[i][j], dp[min(i, vec[k].first)][max(j, vec[k].second)] + 1); } } } int q; cin >> q; while(q--){ int a; cin >> a; if(dp[a][a] == 1e9) cout << "-1\n"; else cout << dp[a][a] << "\n"; } } // g++ -std=gnu++20 pC.cpp -o run -Wall -Wextra -fsanitize=undefined -fsanitize=address
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...