#include <bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);std::cin.tie(0);int m,n;while(cin>>m>>n){map<string,int> rainbow;rainbow.clear();vector colors;colors.clear();colors.resize(n);int colors_over_1 = 0;int diff_color_amount = 0;for(int i = 0 ; i < n ; i ++){cin>>colors[i];rainbow[colors[i]] += 1;if(rainbow[colors[i]] > 1){colors_over_1 += 1;}if(!(i < m - 1)){if(colors_over_1 == 0){diff_color_amount += 1;}rainbow[colors[(i-m+1)]] -= 1;if(rainbow[colors[(i-m+1)]] == 1){colors_over_1 -= 1;}}
}cout<<diff_color_amount<<endl;}}
沒事了忘了加一個條件XD