// khodaya khodet komak kon
# include <bits/stdc++.h>
/*
// ordered_set
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <pll, ll> ppi;
typedef pair <int, pii> pip;
typedef pair <pii, pii> ppp;
# define A first
# define B second
# define endl '\n'
# define sep ' '
# define all(x) x.begin(), x.end()
# define kill(x) return cout << x << endl, 0
# define SZ(x) int(x.size())
# define lc id << 1
# define rc id << 1 | 1
# define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
const int xn = 1e5 + 10;
const int xm = 5e4 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 1e9 + 7;//998244353;
const int base = 257;
int last[xn], ptr, ans;
vector <int> vec[xn];
bitset <xn> bs[xm], ps[xm], tot, res;
int minimumInstructions(int n, int m, int k, vector <int> c, vector <int> a, vector <vector <int> > b){
//cin >> n >> m >> k;
//for (int i = 0; i < n; ++ i)
//cin >> c[i], vec[c[i]].push_back(i);
for (int i = 0; i < n; ++ i)
vec[c[i]].push_back(i);
//for (int i = 0; i < m; ++ i)
//cin >> a[i];
for (int i = 0; i < m; ++ i){
for (int j = 0; j < a[i]; ++ j){
int x = b[i][j];
//cin >> x;
//b[i].push_back(j);
for (int ind : vec[x])
bs[i][ind] = 1;
}
}
ps[0] = bs[0];
for (int i = 1; i < m; ++ i)
ps[i] = (ps[i - 1] & (bs[i] >> i));
res.set();
for (int i = m - 1; i >= 1; -- i){
res = (bs[i] & (res >> 1));
tot |= (res & (ps[i - 1] >> (m - i)));
}
for (int i = 1; i < xn; ++ i){
last[i] = last[i - 1];
if (tot[i])
last[i] = i;
}
if (!tot[0])
return - 1;
while (ptr + m < n){
if (last[ptr + m] == ptr)
return - 1;
++ ans, ptr = last[ptr + m];
}
return ans + 1;
}
/*
int main(){
InTheNameOfGod;
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |