Submission #767001

#TimeUsernameProblemLanguageResultExecution timeMemory
767001dimash241Passport (JOI23_passport)C++17
0 / 100
1 ms340 KiB
#include <cstdio> #include <random> #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <unordered_set> #include <unordered_map> #include <functional> #include <chrono> #define ll long long #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() using namespace std; // вправо, вниз, влево, вверх int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; // ход конем //int dx[] = {-2, -1, 1, 2, 2, 1, -1, -2}; //int dy[] = {1, 2, 2, 1, -1, -2, -2, -1}; mt19937 rnd(chrono::system_clock::now().time_since_epoch().count()); mt19937_64 rnd64(chrono::system_clock::now().time_since_epoch().count()); int rndInteger (int l, int r) { return uniform_int_distribution<int> (l, r)(rnd); } const int MOD = (int) 998244353; const int N = (int) 3e5+7; int n, q; int L[N], R[N]; int ans[N], x[N]; int maxR[N]; int solve(int p) { int res = 1; int r = R[p]; while(r < n) { if(r == maxR[r]) return 1e9; r = maxR[r]; ++res; } return res; } int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) { cin >> L[i] >> R[i]; maxR[L[i]] = max(maxR[L[i]], R[i]); } for (int i = 1; i <= n; ++i) { maxR[i] = max(maxR[i], maxR[i-1]); } cin >> q; for (int i = 1; i <= q; ++i) { cin >> x[i]; cout << solve(x[i]) << '\n'; } return 0; }
#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...