Submission #199116

#TimeUsernameProblemLanguageResultExecution timeMemory
199116godwindDancing Elephants (IOI11_elephants)C++17
0 / 100
5 ms376 KiB
// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O #pragma GCC optimize("Ofast") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx") #include <iostream> #include <vector> #include <algorithm> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <stdio.h> #include <cstdio> #include <math.h> #include <cmath> #include <string> #include <cstring> #include <queue> #include <deque> #include <random> #include <iomanip> #include <bitset> #include <cassert> // #include "grader.h" using namespace std; #define y1 y11 #define double long double #define less less228 #define left left228 #define right right228 #define list list228 template<typename T> void uin(T &a, T b) { if (b < a) a = b; } template<typename T> void uax(T &a, T b) { if (b > a) a = b; } const int N = 150 * 1000 + 228; int n, l; pair<int, int> x[N]; int update(int id, int nv) { int i; for (i = 0; i < n; ++i) { if (x[i].second == id) { x[i].first = nv; while (i && x[i].first < x[i - 1].first) { swap(x[i], x[--i]); } while (i + 1 < n && x[i].first > x[i + 1].first) { swap(x[i], x[++i]); } break; } } int res = 1; int s = x[0].first; for (i = 0; i < n; ++i) { if (x[i].first > s + l) { s = x[i].first; ++res; } } return res; } void init(int nnnn, int llll, int xs[]) { n = nnnn; l = llll; for (int i = 0; i < n; ++i) { x[i].first = xs[i]; x[i].second = i; } return; } // int xx[100]; // signed main() { // cin >> n >> l; // for (int i = 0; i < n; ++i) { // cin >> xx[i]; // } // init(n, l, xx); // while (1) { // int i, j; // cin >> i >> j; // cout << update(i, j) << '\n'; // } // return 0; // }

Compilation message (stderr)

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:58:18: warning: operation on 'i' may be undefined [-Wsequence-point]
     swap(x[i], x[--i]);
                  ^~~
elephants.cpp:61:18: warning: operation on 'i' may be undefined [-Wsequence-point]
     swap(x[i], x[++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...