結果
| 問題 | No.2803 Bocching Star |
| コンテスト | |
| ユーザー |
toku4388
|
| 提出日時 | 2024-07-12 21:09:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 294 ms / 2,000 ms |
| コード長 | 1,683 bytes |
| コンパイル時間 | 1,961 ms |
| コンパイル使用メモリ | 179,896 KB |
| 実行使用メモリ | 14,588 KB |
| 最終ジャッジ日時 | 2024-07-12 21:09:53 |
| 合計ジャッジ時間 | 4,083 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:51:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
51 | for (auto [x, i] : m) {
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#ifdef _DEBUG
#define show(x) \
cerr << #x << " : "; \
showVal(x)
template <typename T>
void showVal(const T &a) {
cerr << a << endl;
}
template <typename T, typename U>
void showVal(const pair<T, U> &a) {
cerr << a.first << " " << a.second << endl;
}
template <typename T>
void showVal(const vector<T> &a) {
for (const T &v : a) cerr << v << " ";
cerr << endl;
}
template <typename T, typename U>
void showVal(const vector<pair<T, U>> &a) {
cerr << endl;
for (const pair<T, U> &v : a) cerr << v.first << " " << v.second << endl;
}
template <typename T, typename U>
void showVal(const map<T, U> &a) {
cerr << endl;
for (const auto &v : a) cerr << "[" << v.first << "] " << v.second << endl;
}
template <typename T>
void showVal(const vector<vector<T>> &a) {
cerr << endl;
for (const vector<T> &v : a) showVal(v);
}
#else
#define show(x)
#endif
int main() {
int n, s;
cin >> n >> s;
vector<int> p(n);
for (int i = 0; i < n; i++) {
cin >> p[i];
}
set<P> m;
for (int i = 0; i < n; i++) {
m.insert({p[i], i});
}
vector<int> ans;
for (auto [x, i] : m) {
show(x);
auto itr = m.find({x, i});
bool isok = true;
for (auto v : {-1, 1}) {
if (itr == m.begin() && v == -1) continue;
auto pv = next(itr, v);
if (pv == m.end()) continue;
show(pv->first);
if (abs((pv->first) - x) <= s) {
isok = false;
}
}
if (isok) {
ans.push_back(i);
}
}
sort(ans.begin(), ans.end());
cout << ans.size() << endl;
int sz = ans.size();
for (int i = 0; i < sz; i++) {
cout << ans[i] + 1;
if (i == sz - 1)
cout << endl;
else
cout << " ";
}
return 0;
}
toku4388