Submission #1012485

#TimeUsernameProblemLanguageResultExecution timeMemory
1012485PacybwoahPassport (JOI23_passport)C++17
0 / 100
0 ms348 KiB
#include<iostream> #include<vector> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int>> dist(n + 1, vector<int>(n + 1, 1e8)); int l, r; for(int i = 1; i <= n; i++){ cin >> l >> r; for(int j = l; j <= r; j++) dist[i][j] = 1; dist[i][i] = 0; } for(int k = 1; k <= n; k++){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } int q; cin >> q; while(q--){ int a; cin >> a; int ans = 1e9; for(int i = 1; i <= n; i++){ ans = min(ans, dist[a][i] + dist[i][1] + dist[i][n]); } if(ans == 1e9) cout << "-1\n"; else cout << ans << "\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...