This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
#ifndef WAIMAI
#include "gondola.h"
#endif
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout (T t, U...u) {cout << t << (sizeof... (u) ? ", " : ""), dout (u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
const int MAX = 2.5e5 + 5;
bitset<MAX> is;
int valid(int n, int a[]) {
int shift = -1;
for (int i = 0; i < n; i++) {
if (a[i] <= n) {
if (shift == -1) shift = (a[i] - 1 - i + n) % n;
else if ((a[i] - 1 - i + n) % n != shift) return 0;
}
if (is[a[i]]) return 0;
is[a[i]] = 1;
}
return 1;
}
int replacement(int n, int a[], int b[]) {
}
const int MOD = 1e9 + 9;
int countReplacement(int n, int a[]) {
}
#ifdef WAIMAI
int gondolaSequence[100001];
int replacementSequence[250001];
int main() {
int i, n, tag;
int nr;
assert (scanf ("%d", &tag) == 1);
assert (scanf ("%d", &n) == 1);
for (i = 0; i < n; i++)
assert ( scanf ("%d", &gondolaSequence[i]) == 1);
switch (tag) {
case 1:
case 2:
case 3:
printf ("%d\n", valid (n, gondolaSequence) );
break;
case 4:
case 5:
case 6:
nr = replacement (n, gondolaSequence, replacementSequence);
printf ("%d ", nr);
if (nr > 0) {
for (i = 0; i < nr - 1; i++)
printf ("%d ", replacementSequence[i]);
printf ("%d\n", replacementSequence[nr - 1]);
} else printf ("\n");
break;
case 7:
case 8:
case 9:
case 10:
printf ("%d\n", countReplacement (n, gondolaSequence) );
break;
}
return 0;
}
#endif
Compilation message (stderr)
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
43 | }
| ^
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
48 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |