結果

問題 No.2517 Right Triangles on Circle
ユーザー rogi52
提出日時 2023-10-27 21:38:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 5,989 bytes
コンパイル時間 3,139 ms
コンパイル使用メモリ 254,760 KB
実行使用メモリ 18,432 KB
最終ジャッジ日時 2024-09-25 13:43:26
合計ジャッジ時間 6,325 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#line 2 "cp-library/src/cp-template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
#line 2 "cp-library/src/utility/rep_itr.hpp"
template < class T > struct itr {
T i, d;
constexpr itr(const T i) noexcept : i(i), d(1) {}
constexpr itr(const T i, const T d) noexcept : i(i), d(d) {}
void operator++() noexcept { i += d; }
constexpr int operator*() const noexcept { return i; }
constexpr bool operator!=(const itr x) const noexcept {
return d > 0 ? i < x.i : i > x.i;
}
};
template < class T > struct rep {
const itr< T > s, t;
constexpr rep(const T t) noexcept : s(0), t(t) {}
constexpr rep(const T s, const T t) noexcept : s(s), t(t) {}
constexpr rep(const T s, const T t, const T d) noexcept : s(s, d), t(t, d) {}
constexpr auto begin() const noexcept { return s; }
constexpr auto end() const noexcept { return t; }
};
template < class T > struct revrep {
const itr < T > s, t;
constexpr revrep(const T t) noexcept : s(t - 1, -1), t(-1, -1) {}
constexpr revrep(const T s, const T t) noexcept : s(t - 1, -1), t(s - 1, -1) {}
constexpr revrep(const T s, const T t, const T d) noexcept : s(t - 1, -d), t(s - 1, -d) {}
constexpr auto begin() const noexcept { return s; }
constexpr auto end() const noexcept { return t; }
};
#line 2 "cp-library/src/utility/io.hpp"
namespace scanner {
struct sca {
template < class T > operator T() {
T s; cin >> s; return s;
}
};
struct vec {
int n;
vec(int n) : n(n) {}
template < class T > operator vector< T >() {
vector< T > v(n);
for(T& x : v) cin >> x;
return v;
}
};
struct mat {
int h,w;
mat(int h, int w) : h(h), w(w) {}
template < class T > operator vector< vector< T > >() {
vector m(h, vector< T >(w));
for(vector< T >& v : m) for(T& x : v) cin >> x;
return m;
}
};
struct speedup {
speedup() {
cin.tie(0);
ios::sync_with_stdio(0);
}
} speedup_instance;
}
scanner::sca in() { return scanner::sca(); }
scanner::vec in(int n) { return scanner::vec(n); }
scanner::mat in(int h, int w) { return scanner::mat(h, w); }
namespace printer {
void precision(int d) {
cout << fixed << setprecision(d);
}
void flush() {
cout.flush();
}
}
template < class T >
ostream& operator<<(ostream& os, const std::vector< T > a) {
int n = a.size();
for(int i : rep(n)) { os << a[i]; if(i != n - 1) os << ' '; }
return os;
}
int print() { cout << '\n'; return 0; }
template < class head, class... tail > int print(head&& h, tail&&... t) {
cout << h; if(sizeof...(tail)) cout << ' ';
return print(forward<tail>(t)...);
}
template < class T > int print_n(const std::vector< T > a) {
int n = a.size();
for(int i : rep(n)) cout << a[i] << "\n";
return 0;
}
#line 2 "cp-library/src/utility/key_val.hpp"
template < class K, class V >
struct key_val {
K key; V val;
key_val() {}
key_val(K key, V val) : key(key), val(val) {}
};
#line 2 "cp-library/src/utility/vec_op.hpp"
template < class T >
key_val< int, T > max_of(const vector< T >& a) {
int i = max_element(a.begin(), a.end()) - a.begin();
return {i, a[i]};
}
template < class T >
key_val< int, T > min_of(const vector< T >& a) {
int i = min_element(a.begin(), a.end()) - a.begin();
return {i, a[i]};
}
template < class T >
T sum_of(const vector< T >& a) {
T sum = 0;
for(const T x : a) sum += x;
return sum;
}
template < class T >
vector<int> freq_of(const vector< T >& a, T L, T R) {
vector<int> res(R - L);
for(const T x : a) res[x - L]++;
return res;
}
template < class T >
vector<int> freq_of(const vector< T >& a, T R) {
return freq_of(a, T(0), R);
}
template < class T >
struct prefix_sum {
vector< T > s;
prefix_sum(const vector< T >& a) : s(a) {
s.insert(s.begin(), T(0));
for(int i : rep(a.size())) s[i + 1] += s[i];
}
// [L, R)
T sum(int L, int R) {
return s[R] - s[L];
}
};
#line 3 "cp-library/src/utility/heap.hpp"
template < class T > using heap_min = std::priority_queue< T, std::vector< T >, std::greater< T > >;
template < class T > using heap_max = std::priority_queue< T, std::vector< T >, std::less< T > >;
#line 21 "cp-library/src/cp-template.hpp"
#line 1 "cp-library/src/algorithm/bin_search.hpp"
template < class T, class F >
T bin_search(T ok, T ng, F& f) {
while(abs(ok - ng) > 1) {
T mid = (ok + ng) / 2;
(f(mid) ? ok : ng) = mid;
}
return ok;
}
template < class T, class F >
T bin_search_real(T ok, T ng, F& f, int step = 80) {
while(step--) {
T mid = (ok + ng) / 2;
(f(mid) ? ok : ng) = mid;
}
return ok;
}
#line 2 "cp-library/src/algorithm/argsort.hpp"
template < class T > std::vector< int > argsort(const std::vector< T > &a) {
std::vector< int > ids((int)a.size());
std::iota(ids.begin(), ids.end(), 0);
std::sort(ids.begin(), ids.end(), [&](int i, int j) {
return a[i] < a[j] || (a[i] == a[j] && i < j);
});
return ids;
}
#line 2 "A.cpp"
int main() {
int N = in(), M = in();
vector<int> A = in(N);
if(M % 2 == 1) return print(0);
map<int,int> mp;
for(int i : rep(N)) mp[A[i]] = i;
ll ans = 0;
for(int i : rep(N)) {
int x = A[i] + M / 2;
if(x <= M and mp.contains(x)) {
ans += N - 2;
}
}
print(ans);
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0