Submission #228732

#TimeUsernameProblemLanguageResultExecution timeMemory
228732osaaateiasavtnlArchery (IOI09_archery)C++14
19 / 100
2098 ms12864 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ii pair <int, int> #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcount #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC int get(vector <int> a, int x, int R) { if (a.size() == 2) return 0; for (int t = 0; t < R; ++t) { for (int i = 0; i < a.size(); i += 2) { if (a[i] > a[i + 1]) swap(a[i], a[i + 1]); } vector <int> b = a; b[1] = a[2]; for (int i = 4; i < a.size(); i += 2) { b[i - 2] = a[i]; } b[(int)b.size() - 2] = a[1]; a = b; } for (int i = 0; i < a.size(); ++i) if (a[i] == x) return i / 2; } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else #define endl '\n' ios_base::sync_with_stdio(0); cin.tie(0); #endif int n, R; cin >> n >> R; R %= 2 * n; int my; cin >> my; vector <int> p(2 * n - 1); for (int i = 0; i < 2 * n - 1; ++i) cin >> p[i]; int ans = 1e10; int start = -1; for (int to = 0; to < 2 * n; ++to) { vector <int> t = p; t.insert(t.begin() + to, my); int nn = get(t, my, R); if (nn <= ans) { ans = nn; start = to / 2; } } #ifdef HOME cout << "ans : " << ans << endl; #endif cout << start + 1 << endl; }

Compilation message (stderr)

archery.cpp: In function 'long long int get(std::vector<long long int>, long long int, long long int)':
archery.cpp:17:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < a.size(); i += 2) {
                         ~~^~~~~~~~~~
archery.cpp:23:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 4; i < a.size(); i += 2) {
                         ~~^~~~~~~~~~
archery.cpp:30:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
archery.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }   
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...