제출 #824094

#제출 시각아이디문제언어결과실행 시간메모리
824094thimote75Comparing Plants (IOI20_plants)C++14
0 / 100
1 ms212 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; using idata = vector<int>; template<typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template<typename T> string to_string (T x) { string S = "["; bool first = true; for (const auto v : x) { if (!first) S += ", "; S += to_string(v); first = false; } S += "]"; return S; } string to_string( string s) { return s; } string to_string(bool b) { return to_string((int) b); } void dbg_out () { cout << endl; } template<typename Head, typename... Tail> void dbg_out (Head H, Tail... T) { cout << to_string(H) << " "; dbg_out(T...); } #ifdef DEBUG # define dbg(...) { cout << "(" << #__VA_ARGS__ << "): "; dbg_out(__VA_ARGS__); } #else # define dbg(...) #endif void shift (idata &r, int count) { idata h; for (int i = count; i < r.size(); i ++) h.push_back(r[i]); for (int i = 0; i < count; i ++) h.push_back(r[i]); r.swap(h); } idata A; void init(int k, idata r) { idata r0 = r; int n = r.size(); A.resize(n); int s = 0; for (int v = n - 1; v >= 0; v --) { int p = -1; int l = -1; for (int i = 0; i < n; i ++) if (r[i] == 0) l = i; assert(l != -1); l -= n; dbg(l, v, r) for (int i = 0; i < n; i ++) { if (r[i] != 0) continue ; int d = i - l; l = i; if (d < k) continue ; p = i; break ; } dbg(p); r[p] = 1e9; for (int g = p - 1; g > p - k; g --) { int u = (g + n) % n; if (r[u] != 0) r[u] --; } A[p] = v; } idata h(n); for (int i = 0; i < n; i ++) { int u = 0; for (int j = i + 1; j < i + k; j ++) if (A[j % n] > A[i]) u ++; h[i] = u; } for (int u : h) cout << u << " "; cout << endl; for (int u : A) cout << u << " "; cout << endl; return; } int compare_plants(int x, int y) { int del = A[x] - A[y]; if (del == 0) return 0; return del / abs(del); }

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

plants.cpp: In function 'void shift(idata&, int)':
plants.cpp:46:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for (int i = count; i < r.size(); i ++)
      |                      ~~^~~~~~~~~~
plants.cpp: In function 'void init(int, idata)':
plants.cpp:106:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  106 |  for (int u : h) cout << u << " "; cout << endl;
      |  ^~~
plants.cpp:106:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  106 |  for (int u : h) cout << u << " "; cout << endl;
      |                                    ^~~~
plants.cpp:107:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  107 |  for (int u : A) cout << u << " "; cout << endl;
      |  ^~~
plants.cpp:107:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  107 |  for (int u : A) cout << u << " "; cout << endl;
      |                                    ^~~~
plants.cpp:62:6: warning: unused variable 's' [-Wunused-variable]
   62 |  int s = 0;
      |      ^
#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...