//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define KeepUnique(v) (v).erase( unique(all(v)), v.end() )
#define MEMSET(a,val) memset(a, val, sizeof a)
#define PB push_back
#define endl '\n'
inline int myrand(int l, int r) {
int ret = rand(); ret <<= 15; ret ^= rand();
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
return ret;
}
template <typename F, typename S>
ostream& operator << (ostream& os, const pair< F, S>& p) {
return os<<"(" <<p.first<<", "<<p.second<<")"; }
typedef pair<int, int> ii;
template<typename T> using min_pq =
priority_queue<T, vector<T>, greater<T> >;
//int dx[] = {-1, +0, +1, +0};
//int dy[] = {+0, +1, +0, -1};
int valid(int n, int inputSeq[]) {
int idx = -1, id = -1;
for(int i = 0; i < n; i++) {
if(inputSeq[i] <= n) {
idx = i, id = inputSeq[i];
break;
}
}
if(idx == -1) {
set<int> st(inputSeq, inputSeq + n);
return int(st.size() == n);
}
vector<int> v(n);
int flag = 1;
for(int val = id, i = idx; val != id or flag; val = val == n ? 1 : val + 1, i = (i + 1) % n) {
v[i] = val; flag = 0;
}
//for(int i = 0; i < n; i++) cerr << inputSeq[i] << ' '; cerr << endl;
//for(int i = 0; i < n; i++) cerr << v[i] << ' '; cerr << endl;
for(int i = 0; i < n; i++) {
if(inputSeq[i] <= n) {
if(inputSeq[i] != v[i])
return 0;
}
} return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
return -2;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
Compilation message
gondola.cpp: In function 'int myrand(int, int)':
gondola.cpp:17:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
^~
gondola.cpp:17:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if(ret < 0) ret = -ret; ret %= (r-l+1); ret += l;
^~~
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:42:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
return int(st.size() == n);
~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
360 KB |
Output is correct |
3 |
Correct |
3 ms |
360 KB |
Output is correct |
4 |
Correct |
3 ms |
572 KB |
Output is correct |
5 |
Correct |
2 ms |
572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
572 KB |
Output is correct |
2 |
Correct |
2 ms |
572 KB |
Output is correct |
3 |
Correct |
3 ms |
572 KB |
Output is correct |
4 |
Correct |
2 ms |
572 KB |
Output is correct |
5 |
Correct |
2 ms |
572 KB |
Output is correct |
6 |
Correct |
8 ms |
1188 KB |
Output is correct |
7 |
Correct |
19 ms |
1972 KB |
Output is correct |
8 |
Correct |
15 ms |
2236 KB |
Output is correct |
9 |
Correct |
9 ms |
2236 KB |
Output is correct |
10 |
Correct |
14 ms |
2924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2924 KB |
Output is correct |
2 |
Correct |
2 ms |
2924 KB |
Output is correct |
3 |
Correct |
3 ms |
2924 KB |
Output is correct |
4 |
Correct |
2 ms |
2924 KB |
Output is correct |
5 |
Correct |
3 ms |
2924 KB |
Output is correct |
6 |
Correct |
12 ms |
2924 KB |
Output is correct |
7 |
Correct |
15 ms |
3836 KB |
Output is correct |
8 |
Correct |
12 ms |
4084 KB |
Output is correct |
9 |
Correct |
6 ms |
4084 KB |
Output is correct |
10 |
Correct |
17 ms |
4760 KB |
Output is correct |
11 |
Incorrect |
3 ms |
4760 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4760 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4760 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4760 KB |
Integer -2 violates the range [0, 350000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4760 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4760 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4760 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4760 KB |
Integer -3 violates the range [0, 1000000008] |
2 |
Halted |
0 ms |
0 KB |
- |