結果

問題 No.1045 直方体大学
ユーザー stoqstoq
提出日時 2021-08-04 20:30:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 5,500 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 209,088 KB
最終ジャッジ日時 2025-01-23 14:04:43
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from main.cpp:5:
In function ‘typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int*; _Tp = int]’,
    inlined from ‘void std::__fill_a1(__gnu_cxx::__normal_iterator<_Iterator, _Container>, __gnu_cxx::__normal_iterator<_Iterator, _Container>, const _Tp&) [with _Ite = int*; _Cont = vector<int>; _Tp = int]’ at /usr/include/c++/13/bits/stl_algobase.h:960:21,
    inlined from ‘void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = int]’ at /usr/include/c++/13/bits/stl_algobase.h:977:21,
    inlined from ‘void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Tp = int]’ at /usr/include/c++/13/bits/stl_algobase.h:1007:20,
    inlined from ‘void BellmanFord<T>::calc(int) [with T = int]’ at main.cpp:145:9,
    inlined from ‘void solve()’ at main.cpp:256:10:
/usr/include/c++/13/bits/stl_algobase.h:929:17: warning: ‘bf.BellmanFord<int>::INF’ may be used uninitialized [-Wmaybe-uninitialized]
  929 |       const _Tp __tmp = __value;
      |                 ^~~~~
main.cpp: In function ‘void solve()’:
main.cpp:223:20: note: ‘bf’ declared here
  223 |   BellmanFord<int> bf(n * 3 + 1, INF);
      |                    ^~

ソースコード

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

#define MOD_TYPE 1
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#if 1
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#if 0
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <typename T>
using extset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif
#if 0
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
#endif
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename T>
using smaller_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-7;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};
#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";
struct io_init
{
io_init()
{
cin.tie(0);
ios::sync_with_stdio(false);
cout << setprecision(30) << setiosflags(ios::fixed);
};
} io_init;
template <typename T>
inline bool chmin(T &a, T b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
inline ll CEIL(ll a, ll b)
{
return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
is >> p.first >> p.second;
return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
os << p.first << " " << p.second;
return os;
}
#pragma endregion
random_device seed_gen;
mt19937_64 engine(seed_gen());
// --------------------------------------
template <typename T>
struct BellmanFord
{
struct edge
{
int from, to;
T cost;
};
int V;
T INF;
vector<edge> E;
vector<T> d;
vector<bool> negative;
BellmanFord(int V, T INF = 4e18) : V(V), d(V), negative(V) {}
void add_edge(int a, int b, T c, bool directed = true)
{
E.push_back(edge{a, b, c});
if (!directed)
E.push_back(edge{b, a, c});
}
void calc(int s)
{
fill(all(d), INF);
d[s] = 0;
bool update;
while (1)
{
update = false;
for (auto e : E)
{
if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost)
{
d[e.to] = d[e.from] + e.cost;
update = true;
}
}
if (!update)
return;
}
}
bool calc_and_find_negative_loop(int s, int g = -1)
{
fill(all(d), INF);
fill(all(negative), false);
d[s] = 0;
rep(i, V)
{
bool update = false;
for (auto e : E)
{
if (d[e.from] != LINF && d[e.to] > d[e.from] + e.cost)
{
d[e.to] = d[e.from] + e.cost;
update = true;
if (i == V - 1)
negative[e.from] = negative[e.to] = true;
}
}
if (!update)
return false;
}
if (g == -1)
{
rep(i, V)
{
if (negative[i])
return true;
}
return false;
}
else
{
return negative[g];
}
}
bool find_any_negative_loop()
{
vector<T> d_(V);
rep(i, V) for (auto e : E)
{
if (d_[e.to] > d_[e.from] + e.cost)
{
d_[e.to] = d_[e.from] + e.cost;
if (i == V - 1)
return true;
}
}
return false;
}
};
void solve()
{
int n;
cin >> n;
int a[16][3];
rep(i, n) rep(j, 3) cin >> a[i][j];
BellmanFord<int> bf(n * 3 + 1, INF);
const int S = n * 3;
rep(i, n) rep(j, n)
{
if (i == j)
continue;
if (a[i][0] >= a[j][0] and a[i][1] >= a[j][1])
;
rep(k, 3) rep(l, 3)
{
int h1 = a[i][k], h2 = a[j][l];
int a1, b1;
if (k == 0)
a1 = a[i][1], b1 = a[i][2];
if (k == 1)
a1 = a[i][0], b1 = a[i][2];
if (k == 2)
a1 = a[i][0], b1 = a[i][1];
int a2, b2;
if (l == 0)
a2 = a[j][1], b2 = a[j][2];
if (l == 1)
a2 = a[j][0], b2 = a[j][2];
if (l == 2)
a2 = a[j][0], b2 = a[j][1];
if (a1 < a2 and b1 < b2 or a1 < b2 and b1 < a2)
bf.add_edge(i + n * k, j + n * l, -h2);
}
}
rep(i, n) rep(k, 3)
{
bf.add_edge(S, i + n * k, -a[i][k]);
}
bf.calc(S);
int ans = 0;
rep(i, n * 3) chmax(ans, -bf.d[i]);
cout << ans << "\n";
}
int main()
{
solve();
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0