QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#346531 | #4772. Movie collection | PetroTarnavskyi# | AC ✓ | 239ms | 8736kb | C++20 | 1.0kb | 2024-03-08 17:15:25 | 2024-03-08 17:15:26 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
void solve()
{
int n, m;
cin >> n >> m;
VI idx(n);
iota(ALL(idx), 0);
ordered_set s(ALL(idx));
reverse(ALL(idx));
FOR(i, 0, m)
{
int x;
cin >> x;
x--;
if(i)
cout << " ";
cout << n - 1 - s.order_of_key(idx[x]);
s.erase(idx[x]);
idx[x] = n + i + 1;
s.insert(idx[x]);
}
cout << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while(t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
input:
2 3 3 3 1 1 5 3 4 4 5
output:
2 1 0 3 0 4
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 239ms
memory: 8736kb
input:
25 3 3 3 1 1 5 3 4 4 5 84 887 10 20 30 32 11 73 58 74 3 20 63 68 84 71 25 79 17 17 60 57 76 10 3 27 27 56 44 20 6 43 67 55 18 52 2 29 80 59 58 82 34 36 21 74 63 45 24 79 18 83 8 9 9 10 75 75 65 74 10 70 33 76 81 6 83 82 74 78 13 4 31 46 39 52 75 57 52 15 8 25 13 15 33 61 64 24 51 44 13 61 69 1 8 65 ...
output:
2 1 0 3 0 4 9 19 29 31 13 72 58 73 10 7 64 69 83 73 33 79 28 0 66 65 77 18 12 39 0 66 55 15 26 55 73 67 38 65 29 47 80 69 27 82 53 55 47 31 31 62 51 29 15 83 43 44 0 28 80 0 76 11 3 79 59 33 83 29 11 20 8 83 52 49 61 69 66 32 17 41 2 57 21 45 10 3 18 77 79 27 76 43 7 5 81 57 11 28 74 60 64 38 72 55 ...
result:
ok 25 lines