#include <bits/stdc++.h>
//#include "paint.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define N 100100
#define F first
#define S second
#define M ll(1e9 + 7)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define PB push_back
#define sz(x) ll(x.size())
#define pw(x) (1ll << x)
#define pwr(x) ((1ll << x) - 1)
#define _ << " " <<
#define pri(s) cout << s << endl
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
//typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int minimumInstructions(int n, int m, int k, vector<int> c, vector<int> a, vector<vector<int> > b)
{
int who[k];
for (int i = 0; i < k; i++) who[i] = -1;
for (int i = 0; i < m; i++)
for (auto it : b[i]) who[it] = i;
for (int i = 0; i < n; i++) {c[i] = who[c[i]]; if (c[i] == -1) return -1;}
bool mk[n];
memset(mk, 0, sizeof mk);
for (int i = 0; i < n; i++)
if (c[i] == 0)
{
int len = 0;
bool bad = 0;
int cur = i;
while (len < m && cur < n)
{
if (c[cur] != len) {bad = 1; break;}
len++;
cur++;
}
if (len != m) bad = 1;
if (!bad)
{
len = 0;
cur = i;
while (len < m)
{
mk[cur] = 1;
len++;
cur++;
}
}
bad = 0;
len = 0;
cur = i;
while (len < m && cur >= 0)
{
if (c[cur] != (m - len) % m) {bad = 1; break;}
len++;
cur--;
}
if (len != m) bad = 1;
if (!bad)
{
len = 0;
cur = i;
while (len < m)
{
mk[cur] = 1;
len++;
cur--;
}
}
}
for (int i = 0; i < n; i++) if (!mk[i]) return -1;
return n / m + (n % m == 0 ? 0 : 1);
}
//int main()
//{
// ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |