제출 #133894

#제출 시각아이디문제언어결과실행 시간메모리
133894osaaateiasavtnlBubble Sort 2 (JOI18_bubblesort2)C++14
0 / 100
9031 ms884 KiB
#include<bits/stdc++.h> using namespace std; #define app push_back #define ii pair <int, int> #define mp make_pair int get(vector <int> a) { int n = a.size(); int ans = 0; while (1) { auto t = a; sort(t.begin(), t.end()); if (t == a) return ans; for (int i = 0; i + 1 < n; ++i) { if (a[i + 1] < a[i]) swap(a[i], a[i + 1]); } ++ans; } return ans; } vector <int> countScans(vector <int> a, vector <int> p, vector <int> x) { for (auto &e : p) --e; int n = a.size(), q = p.size(); vector <int> ans; for (int i = 0; i < q; ++i) { a[p[i]] = x[i]; ans.app(get(a)); } return ans; } #ifdef HOME signed main() { //freopen("input.txt", "r", stdin); int n, q; cin >> n >> q; vector <int> a(n), p(q), x(q); for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < q; ++i) cin >> p[i] >> x[i]; vector <int> ans = countScans(a, p, x); for (int e : ans) cout << e << '\n'; } #endif

컴파일 시 표준 에러 (stderr) 메시지

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:23:9: warning: unused variable 'n' [-Wunused-variable]
     int n = a.size(), q = p.size();
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...