Submission #759713

#TimeUsernameProblemLanguageResultExecution timeMemory
759713raysh07Gondola (IOI14_gondola)C++17
55 / 100
24 ms5148 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; int valid(int n, int a[]) { set <int> st; for (int i = 0; i < n; i++) st.insert(a[i]); if (st.size() != n) return 0; vector <int> b; for (int i = 0; i < n; i++){ if (a[i] <= n) b.push_back(a[i]); } for (int i = 1; i < b.size(); i++){ int need = b[i - 1] + 1; if (need > n) need = 1; if (b[i] != need) return 0; } return 1; } //---------------------- int replacement(int n, int a[], int b[]) { int mx = 0; for (int i = 0; i < n; i++) mx = max(mx, a[i]); int mn = 1e6; int c[n]; for (int i = 0; i < n; i++) mn = min(mn, a[i]); if (mn > n){ for (int i = 0; i < n; i++) c[i] = i + 1; } else { int p = -1; for (int i = 0; i < n; i++){ if (a[i] <= n) p = i; } c[p] = a[p]; for (int i = p + 1; i < n; i++){ c[i] = c[i - 1] + 1; if (c[i] > n) c[i] = 1; } if (p != 0){ c[0] = c[n - 1] + 1; if (c[0] > n) c[0] = 1; for (int i = 1; i < p; i++){ c[i] = c[i - 1] + 1; if (c[i] > n) c[i] = 1; } } } int l = 0; set <pair<int, int>> st; for (int i = 0; i < n; i++){ if (c[i] != a[i]){ st.insert(make_pair(a[i], i)); } } int repl = n + 1; while (st.size()){ auto u = *st.begin(); b[l++] = c[u.second]; c[u.second] = repl++; if (c[u.second] == a[u.second]) st.erase(u); } return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:10:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     if (st.size() != n) return 0;
      |         ~~~~~~~~~~^~~~
gondola.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 1; i < b.size(); i++){
      |                     ~~^~~~~~~~~~
#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...