QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#601685 | #6701. BaoBao Loves Reading | PonyHex | WA | 1ms | 3880kb | C++20 | 2.6kb | 2024-09-30 10:51:19 | 2024-09-30 10:51:21 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define ll long long
#define double long double
#define lc u<<1
#define rc u<<1|1
#define X first
#define Y second
#define endl "\n"
//#define int long long
const int N = 1e5 + 50;
const int M = 2e5 + 5;
const ll maxm = 1e18 + 5;
const ll mod = 998244353;
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
//random_shuffle(id + 1, id + n + 1);
ll ksm(ll a, ll b);
ll gcd(ll a, ll b);
template<class T>inline void read(T& x) {
x = 0;
char c = getchar();
while (!isdigit(c))c = getchar();
while (isdigit(c))x = x * 10 + (c & 15), c = getchar();
}
void write(ll x)
{
if (x < 0)
putchar('-'), x = -x;
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
return;
}
ll a[N], ans[N];
void solve()
{
//先理解一下题意,假设现在容量为3,那么我们完全可以以4为区间长度
//滑动窗口,判断区间内不同的元素的数量,不对,还是要区间长度3来模拟
//动态出入,走一遍,已知记录队列中不同元素的个数即可
//比如,当前队列中有3个不同的元素,放入一个元素还是三个
//这个时候,应该判断3的位置,
//有点思路,我们遍历走到某个节点的时候,如果见到了元素3
//元素3会被放到书桌的最上方,判断3,是否会被放回书架在拿回来
//我们应该判断到下一个3,这段区间内有多少个不同的元素
//只有不同的元素才会将3不断向后放,
//ans还会加上数组内不同元素的个数,因为在初次入队的时候,
//那些元素是从书架上拿下来的
ll n; cin >> n;
unordered_map<ll, ll>ex;
for (int i = 1; i <= n; i++)cin >> a[i], ex[a[i]] = 1, ans[i] = 0;
unordered_map<ll, ll>pos;
for (int i = 1; i <= n; i++) {
if (pos[a[i]] == 0) {
pos[a[i]] = i; continue;
}
ll dis = i - pos[a[i]];
ans[1]++; ans[dis]--;
pos[a[i]] = i;
}
ll mid = 0;
for (int i = 1; i <= n; i++) {
mid += ans[i];
ans[i] = mid;
}
cout << ans[1] + ex.size();
for (int i = 2; i <= n; i++)cout << " " << ans[i] + ex.size();
cout << endl;
return;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
cin >> T;
//read(T);
while (T--)
solve();
return 0;
}
/*PonyHex*/
ll ksm(ll a, ll b) {
ll base = a;
ll ans = 1;
while (b) {
if (b & 1)ans *= base % mod;
ans %= mod;
base *= base; base %= mod;
b >>= 1;
}
return ans % mod;
}
ll gcd(ll a, ll b) {
return b ? gcd(b, a % b) : a;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
1 7 4 3 4 2 3 1 4
output:
7 6 5 4 4 4 4
result:
ok single line: '7 6 5 4 4 4 4'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3880kb
input:
100 73 45 45 2 2 2 45 35 45 16 35 16 45 35 2 16 16 45 2 45 45 16 35 35 16 35 35 2 2 2 35 45 35 45 35 16 35 2 2 16 35 16 45 45 16 45 2 16 16 35 16 45 16 45 45 16 16 35 35 35 35 45 45 45 35 16 16 16 2 16 16 35 16 2 83 78 52 7 35 33 82 51 27 45 34 17 51 55 25 26 11 52 41 25 41 13 46 33 83 83 7 40 51 33...
output:
51 36 30 22 19 18 16 13 7 7 5 5 5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 80 77 75 74 71 68 66 66 64 64 62 59 58 57 55 53 52 49 49 48 48 47 46 46 46 44 43 43 41 41 41 40 40 40 38 37 37 36 36 36 35 35 35 35 35 34 34 32 32...
result:
wrong answer 1st lines differ - expected: '51 30 17 4 4 4 4 4 4 4 4 4 4 4...4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4', found: '51 36 30 22 19 18 16 13 7 7 5 ...4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4'