49332023-04-07 14:44:56SleepyOverlordSzínes szobák (50 pont)cpp17Time limit exceeded 24/50368ms10228 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

int n, c, q;
VI color, cnt;
VVI byColor;

int main()
{
	cin >> n >> c >> q;
	color.RS(n + 2);
	cnt.RS(n + 2);
	byColor.RS(c + 1);
	FOR(i, 1, n) 
	{
		cin >> color[i];
		cnt[i] = 1;
		byColor[color[i]].PB(i);
	}

	FOR(i, 1, q)
	{
		int color, delta;
		cin >> color >> delta;
		if (delta == -1)
			for (int i : byColor[color]) 
			{
				cnt[i + delta] += cnt[i];
				cnt[i] = 0;
			}
		else
			FORD(j, byColor[color].SZ - 1, 0)
			{
				int i = byColor[color][j];
				cnt[i + delta] += cnt[i];
				cnt[i] = 0;
			}
	}

	cout << cnt[0] + cnt[n + 1];

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base24/50
1Accepted0/03ms1872 KiB
2Accepted0/093ms10228 KiB
3Accepted1/14ms2512 KiB
4Accepted1/14ms2720 KiB
5Accepted1/14ms2876 KiB
6Accepted1/14ms3092 KiB
7Accepted1/14ms3304 KiB
8Accepted1/14ms3260 KiB
9Accepted1/14ms3332 KiB
10Accepted1/16ms3624 KiB
11Accepted1/14ms3472 KiB
12Accepted1/16ms3516 KiB
13Accepted1/137ms3912 KiB
14Accepted1/114ms4276 KiB
15Accepted1/117ms4232 KiB
16Accepted1/154ms4372 KiB
17Accepted1/168ms4520 KiB
18Accepted1/168ms4436 KiB
19Accepted1/159ms7580 KiB
20Accepted1/189ms7552 KiB
21Accepted1/168ms7556 KiB
22Accepted1/174ms7652 KiB
23Accepted1/183ms7676 KiB
24Accepted1/190ms7696 KiB
25Accepted1/189ms7676 KiB
26Accepted1/190ms7564 KiB
27Time limit exceeded0/3347ms7432 KiB
28Time limit exceeded0/3340ms7376 KiB
29Time limit exceeded0/3360ms7488 KiB
30Time limit exceeded0/3368ms7444 KiB
31Time limit exceeded0/3360ms7444 KiB
32Time limit exceeded0/3363ms7624 KiB
33Time limit exceeded0/4361ms5496 KiB
34Time limit exceeded0/4361ms5556 KiB