QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201421#1955. Double Rainbowstd_abs#WA 0ms3756kbC++17806b2023-10-05 14:14:402023-10-05 14:14:40

Judging History

你现在查看的是最新测评结果

  • [2023-10-05 14:14:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3756kb
  • [2023-10-05 14:14:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int)a.size())
const int N = 10005;

int n,k,a[N],cnt[N],cnt2[N];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> k;
    for(int i=0; i<n; ++i) cin >> a[i],a[i]--,cnt[a[i]]++;
    int res=1e9;
    for(int i=0; i<n; ++i){
        int x=0;
        memset(cnt2,0,sizeof cnt2);
        for(int j=i; j<n; ++j){
            if(!cnt2[a[j]]) x++;
            if(x==k){
                res=min(res,j-i+1);
                break;
            }
            cnt2[a[j]]++;
            if(cnt2[a[j]]==cnt[a[j]]) break;
        }
    }
    if(res>1e8) cout << "0\n";
    else cout << res << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3756kb

input:

1 1
1

output:

1

result:

wrong answer 1st lines differ - expected: '0', found: '1'