QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#257015 | #1955. Double Rainbow | superduchackgv | WA | 1ms | 3448kb | C++20 | 1.7kb | 2023-11-18 23:35:51 | 2023-11-18 23:35:51 |
Judging History
answer
#include<bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define vt vector
#define ins insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
typedef unsigned long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef vt<int> vti;
const double Pi = acos(- 1.0);
template<typename T>ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {for(T x : vec) cout << x << ' '; cout << endl;return os;}
const int inf = INT_MAX;
void Duck(){
int n; cin >> n;
int k; cin >> k;
vti a(n), cnt(k + 1);
for(int i = 0; i < n; i++){
cin >> a[i];
cnt[a[i]]++;
}
int l = 0, r = 0;
int ans = n;
for(int l = 0; l < n; l++){
vti cnt1 = cnt;
vti cnt2(k + 1);
int r = l;
set<int> s;
while(r < n && s.size() < k){
s.ins(a[r]);
cnt2[a[r]]++;
cnt1[a[r]]--;
r++;
}
bool ok = 1;
for(int i = 1; i <= k; i++){
if(cnt1[i] == 0 || cnt2[i] == 0){
ok = 0;
}
}
if(ok){
ans = min(ans, n - (r - l));
}
}
cout << (ans == n ? 0 : ans) << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
/*Duck3*/
int t = 1;
//freopen("input.txt", "r", stdin);
while(t--) Duck();
return 0;
}
/*
Test:
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3408kb
input:
1 1 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
2 1 1 1
output:
1
result:
ok single line: '1'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3436kb
input:
10000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
9999
result:
wrong answer 1st lines differ - expected: '1', found: '9999'