Submission #73906420


Source Code Expand

#include <bits/stdc++.h>
#define ll long long
const ll N = 2e5 + 5, MOD = 998244353, inf = 2e18;
using namespace std;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
char di[] = {'R', 'L', 'D', 'U'};
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

void Ebraam() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
#endif
}

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> v(n), tmp(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    tmp = v;
    sort(tmp.begin(), tmp.end());
    while (q--) {
        int x;
        cin >> x;
        vector<int> g(x);
        for (int i = 0; i < x; i++) {
            cin >> g[i];
        }
        bool f = 0;
        sort(g.begin(), g.end(), [&](int i, int j) {
            return v[i - 1] < v[j - 1];
        });
        for (int i = 0; i < x; i++) {
            if (tmp[i] != v[g[i] - 1]) {
                cout << tmp[i] << '\n';
                f = 1;
                break;
            }
        }
        if (!f)cout << tmp[x] << '\n';
    }
}

int main() {
    Ebraam();
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
        if (t)cout << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task C - Except and Min
User Ebraam_Yousef
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1677 Byte
Status AC
Exec Time 54 ms
Memory 5752 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 19
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 02_random_2_00.txt, 02_random_2_01.txt, 02_random_2_02.txt, 02_random_2_03.txt, 02_random_2_04.txt, 02_random_2_05.txt, 03_random_3_00.txt, 03_random_3_01.txt, 03_random_3_02.txt, 03_random_3_03.txt, 03_random_3_04.txt, 03_random_3_05.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3504 KiB
01_random_00.txt AC 54 ms 5752 KiB
01_random_01.txt AC 37 ms 5668 KiB
01_random_02.txt AC 54 ms 5600 KiB
01_random_03.txt AC 54 ms 5704 KiB
01_random_04.txt AC 51 ms 5668 KiB
01_random_05.txt AC 49 ms 5600 KiB
02_random_2_00.txt AC 52 ms 5736 KiB
02_random_2_01.txt AC 52 ms 5704 KiB
02_random_2_02.txt AC 44 ms 5632 KiB
02_random_2_03.txt AC 52 ms 5628 KiB
02_random_2_04.txt AC 42 ms 5704 KiB
02_random_2_05.txt AC 41 ms 5628 KiB
03_random_3_00.txt AC 53 ms 5628 KiB
03_random_3_01.txt AC 52 ms 5616 KiB
03_random_3_02.txt AC 52 ms 5592 KiB
03_random_3_03.txt AC 52 ms 5572 KiB
03_random_3_04.txt AC 53 ms 5624 KiB
03_random_3_05.txt AC 51 ms 5668 KiB