Submission #296180

#TimeUsernameProblemLanguageResultExecution timeMemory
296180arayiGondola (IOI14_gondola)C++17
55 / 100
27 ms3444 KiB
#include <bits/stdc++.h> #include "gondola.h" #define ad push_back #define MP make_pair #define fr first #define sc second using namespace std; const int N = 3e5 + 20; bool col[N]; int valid(int n, int inputSeq[]) { vector <int> a; for (int i = 0; i < n; i++) a.ad(inputSeq[i]); for (int i = 0; i < n; i++) a.ad(inputSeq[i]); int i1 = -1; for (int i = 0; i < n; i++) { if(col[a[i]]) return 0; col[a[i]] = true; if(a[i] <= n) { i1 = (i - a[i] + 1 + n) % n; } } if(i1 == -1) return 1; for (int i = i1; i < i1 + n; i++) { if(a[i] > n) continue; if(i - i1 + 1 != a[i]) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vector <int> a, pat; for (int i = 0; i < n; i++) a.ad(gondolaSeq[i]); for (int i = 0; i < n; i++) a.ad(gondolaSeq[i]); int i1 = 0; for (int i = 0; i < n; i++) { if(a[i] <= n) i1 = (i - a[i] + 1 + n) % n; } vector <pair<int, int> > fp; int nw = n + 1; for (int i = i1; i < i1 + n; i++) { fp.ad(MP(a[i], i - i1 + 1)); } sort(fp.begin(), fp.end()); for (int i = 0; i < fp.size(); i++) { while(nw <= fp[i].fr) { pat.ad(fp[i].sc); fp[i].sc = nw; nw++; } } for (int i = 0; i < pat.size(); i++) replacementSeq[i] = pat[i]; return (int)pat.size(); } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:55:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for (int i = 0; i < fp.size(); i++)
      |                   ~~^~~~~~~~~~~
gondola.cpp:64:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |   for (int i = 0; i < pat.size(); i++) replacementSeq[i] = pat[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...