Submission #730232

#TimeUsernameProblemLanguageResultExecution timeMemory
730232becaidoGondola (IOI14_gondola)C++17
25 / 100
8 ms596 KiB
#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 (i, 0, n - 1) { 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 p[MAX]; int replacement(int n, int a[], int b[]) { int mx = *max_element(a, a + n); fill(p + 1, p + mx + 1, 0); int shift = -1; FOR (i, 0, n - 1) { p[a[i]] = i; if (a[i] <= n && shift == -1) shift = (a[i] - 1 - i + n) % n; } if (shift == -1) shift = 0; FOR (i, 1, n) p[i] = (i - 1 - shift + n) % n; FOR (i, 1, n) a[p[i]] = i; int sz = 0; FOR (i, n + 1, mx) b[sz++] = a[p[i]], a[p[i]] = i; return sz; } 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 countReplacement(int, int*)':
gondola.cpp:61:1: warning: no return statement in function returning non-void [-Wreturn-type]
   61 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...