1100B - Build a Contest - CodeForces Solution


data structures implementation *1300

Please click on ads to support us..

Python Code:

dificuldade_max, _ = map(int, input().split())

frequencias = {}
dificuldades = list(map(int, input().split(" ")))
resultado = ""

conjunto_questoes = 0
for dificuldade in dificuldades:
    if not(dificuldade in frequencias) or frequencias[dificuldade] == 0:
        conjunto_questoes += 1
        frequencias[dificuldade] = 1

        if conjunto_questoes == dificuldade_max:
            resultado += "1"
        else:
            resultado += "0"
    else:
        resultado += "0"
        frequencias[dificuldade] += 1

    if conjunto_questoes == dificuldade_max:
        for dif in frequencias.keys():
            frequencias[dif] -= 1

            if frequencias[dif] == 0:
                conjunto_questoes -= 1

print(resultado)

C++ Code:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <functional>
#include <list>
#include <sstream>

using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define debug(a) cout<<#a<<"="<<a<<endl
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef double db;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N = 1e5+10;

int a[N];
int cnt[N];
int ans[N];

void solve()
{
	int n,m;
	cin >> n >> m;
	rep(i,1,m)
		ans[i] = n;
	rep(i,1,m){
		int x;
		cin >> x;
		cnt[x]++;
		ans[cnt[x]]--;
		if(ans[cnt[x]] == 0)
			cout << 1;
		else
			cout << 0;
	}
	cout << endl;
}

int main()
{
	IOS;
	
	int t;
	t = 1;
	while(t--){
		solve();
	}

 	return 0;
}



 	   		 	  		 	 				 			 			 		


Comments

Submit
0 Comments
More Questions

1668A - Direction Change
1667B - Optimal Partition
1668B - Social Distance
88B - Keyboard
580B - Kefa and Company
960A - Check the string
1220A - Cards
897A - Scarborough Fair
1433B - Yet Another Bookshelf
1283B - Candies Division
1451B - Non-Substring Subsequence
1408B - Arrays Sum
1430A - Number of Apartments
1475A - Odd Divisor
1454B - Unique Bid Auction
978C - Letters
501B - Misha and Changing Handles
1496A - Split it
1666L - Labyrinth
1294B - Collecting Packages
1642B - Power Walking
1424M - Ancient Language
600C - Make Palindrome
1669D - Colorful Stamp
1669B - Triple
1669A - Division
1669H - Maximal AND
1669E - 2-Letter Strings
483A - Counterexample
3C - Tic-tac-toe