Submission #883894

#TimeUsernameProblemLanguageResultExecution timeMemory
883894vjudge1Passport (JOI23_passport)C++17
40 / 100
2047 ms54176 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' const int N = 2500+100, M = 1e5+10, K = 21; int n, dp[N][N]; array<int, 2> a[N]; int dfs(int l, int r){ if(dp[l][r] != MOD) return dp[l][r]; for(int i = l; i <= r; ++i){ int L = min(l, a[i][0]); int R = max(r, a[i][1]); if(R > r || L < l) dp[l][r] = min(dp[l][r], dfs(L, R) + 1); } return dp[l][r]; } void solve(){ cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i][0] >> a[i][1]; for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) dp[i][j] = MOD; dp[1][n] = 0; int q; cin >> q; for(int i = 1; i <= q; ++i){ int v; cin >> v; int ans = dfs(v, v); cout << (ans == MOD ? -1 : ans) << '\n'; } } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(tt--){ solve(); } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

Compilation message (stderr)

passport.cpp: In function 'int main()':
passport.cpp:41:15: warning: unused variable 'aa' [-Wunused-variable]
   41 |   int tt = 1, aa;
      |               ^~
#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...