답안 #887317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887317 2023-12-14T09:03:06 Z HossamHero7 Passport (JOI23_passport) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(auto &[a,b] : v) cin>>a>>b , a -- , b--;
    int q;
    cin>>q;
    while(q--){
        int x;
        cin>>x;
        x --;
        queue<pair<int,int>> q;
        q.push(v[x]);
        vector<vector<int>> dep(n,vector<int>(n));
        vector<vector<bool>> vis(n,vector<bool>(n));
        vis[v[x].first][v[x].second] = 1;
        while(q.size()){
            auto [l,r] = q.front();      q.pop();
            for(int i=l;i<=r;i++){
                int L = min(l,v[i].first);
                int R = max(r , v[i].second);
                if(vis[L][R]) continue;
                q.push({L,R});
                vis[L][R] = 1;
                dep[L][R] = dep[l][r] + 1;
            }
        }
        cout<<dep[0][n-1] + 1<<endl;
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Compilation message

passport.cpp: In function 'void solve()':
passport.cpp:9:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
    9 |     for(auto &[a,b] : v) cin>>a>>b , a -- , b--;
      |               ^
passport.cpp:22:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |             auto [l,r] = q.front();      q.pop();
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -