結果
| 問題 |
No.3269 Leq-K Partition
|
| コンテスト | |
| ユーザー |
apricity
|
| 提出日時 | 2025-08-11 22:09:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,331 bytes |
| コンパイル時間 | 1,195 ms |
| コンパイル使用メモリ | 119,028 KB |
| 実行使用メモリ | 15,944 KB |
| 最終ジャッジ日時 | 2025-08-11 22:09:15 |
| 合計ジャッジ時間 | 10,556 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 21 |
ソースコード
// #pragma GCC target("prefer-vector-width=512")
#pragma GCC optimize("Ofast,unroll-loops")
#include <iostream>
#include <vector>
#include <thread>
using namespace std;
constexpr int MX = 100000;
constexpr int B = 32;
int n;
int a[MX];
bool vis[B][MX];
int ans[MX+1];
int calc(int k, int idx) {
int pre = 0;
int res = 0;
int distinct = k;
for (int i = 0; i < n; i++) {
if (not vis[idx][a[i]]) {
if (distinct == k) {
res++;
for (int j = pre; j < i; j++) vis[idx][a[j]] = false;
distinct = 1;
pre = i;
}
else {
distinct++;
}
vis[idx][a[i]] = true;
}
}
for (int i = pre; i < n; i++) vis[idx][a[i]] = false;
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i]; a[i]--;
}
int i = 0;
thread th[B];
for (; i < n; i += B) {
for (int j = 0; j < B; j++) {
th[j] = thread([&,i,j]{
ans[i+j+1] = calc(i+j+1, j);
});
}
for (int j = 0; j < B; j++) th[j].join();
}
for (; i < n; i++) ans[i+1] = calc(i+1, 0);
for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
}
apricity