Submission #586219

#TimeUsernameProblemLanguageResultExecution timeMemory
586219TekorGondola (IOI14_gondola)C++17
55 / 100
31 ms4816 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #define pii pair <int,int> #define f first #define s second #define mp make_pair #define pb push_back #define all(v) v.begin(),v.end() #define ll long long int valid(int n, int a[]) { int c[n + 10]; map <int,int> was; for(int i = 0;i < n;i++) { if(a[i] <= n) { int tek = a[i]; c[i] = tek; for(int j = i + 1;j < n;j++) { tek++; if(tek == n + 1)tek = 1; c[j] = tek; } for(int j = 0;j < i;j++) { tek++; if(tek == n + 1)tek = 1; c[j] = tek; } break; } } for(int i = 0;i < n;i++) { if(a[i] <= n && c[i] != a[i])return 0; if(was[a[i]])return 0; was[a[i]] = 1; } return 1; } /* 1 30 16 26 18 19 20 13 22 21 24 25 17 27 28 29 30 1 2 3 11 5 6 8 7 9 10 12 4 23 14 15 */ //---------------------- int replacement(int n, int a[], int b[]) { int c[n + 1]; bool ch = 0; for(int i = 0;i < n;i++) { if(a[i] <= n) { int tek = a[i]; c[i] = tek; for(int j = i + 1;j < n;j++) { tek++; if(tek == n + 1)tek = 1; c[j] = tek; } for(int j = 0;j < i;j++) { tek++; if(tek == n + 1)tek = 1; c[j] = tek; } ch = 1; break; } } if(!ch) { for(int i = 0;i < n;i++) { c[i] = i + 1; } } set <pii> g; for(int i = 0;i < n;i++) { if(a[i] > n)g.insert(mp(a[i],i)); } int k = 0; int cnt = n + 1; while(!g.empty()) { pii vv = *(g.begin()); int val = vv.f,bilo = c[vv.s]; while(1) { b[k++] = bilo; if(cnt == val) { cnt++; break; } bilo = cnt++; } g.erase(vv); } return k; } /* 4 2 3 2 */ //---------------------- int countReplacement(int n, int a[]) { int d[n + 10]; bool ch = 0; for(int i = 0;i < n;i++) { if(a[i] <= n) { d[i] = 0; ch = 1; }else d[i] = a[i] - n; } sort(d,d + n); ll ans = 1; return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:102:7: warning: variable 'ch' set but not used [-Wunused-but-set-variable]
  102 |  bool ch = 0;
      |       ^~
gondola.cpp:110:5: warning: unused variable 'ans' [-Wunused-variable]
  110 |  ll ans = 1;
      |     ^~~
#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...