結果
| 問題 |
No.497 入れ子の箱
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-27 17:02:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,344 bytes |
| コンパイル時間 | 399 ms |
| コンパイル使用メモリ | 48,972 KB |
| 最終ジャッジ日時 | 2024-11-14 19:59:52 |
| 合計ジャッジ時間 | 1,274 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:14:23: error: variable 'std::array<int, 3> a' has initializer but incomplete type
14 | array<int, 3> a = {{ x[i], y[i], z[i] }};
| ^
main.cpp: In lambda function:
main.cpp:6:68: error: no matching function for call to 'begin(int&)'
6 | #define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
| ~~~~~^~~~~~~
main.cpp:15:9: note: in expansion of macro 'whole'
15 | whole(sort, a);
| ^~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_vector.h:63,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:64,
from main.cpp:2:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)'
90 | begin(initializer_list<_Tp> __ils) noexcept
| ^~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/initializer_list:90:5: note: template argument deduction/substitution failed:
main.cpp:6:68: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
6 | #define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
| ~~~~~^~~~~~~
main.cpp:15:9: note: in expansion of macro 'whole'
15 | whole(sort, a);
| ^~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/vector:67:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/range_access.h:52:5: note: candidate: 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&)'
52 | begin(_Container& __cont) -> decltype(__cont.begin())
|
ソースコード
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
int main() {
int n; scanf("%d", &n);
vector<int> x(n), y(n), z(n); repeat (i,n) scanf("%d%d%d", &x[i], &y[i], &z[i]);
vector<vector<int> > g(n);
vector<int> indegree(n);
repeat (i,n) {
array<int, 3> a = {{ x[i], y[i], z[i] }};
whole(sort, a);
repeat (j,n) {
bool found = false;
do {
if (a[0] < x[j] and a[1] < y[j] and a[2] < z[j]) {
found = true;
}
} while (whole(next_permutation, a));
if (found) {
g[j].push_back(i);
indegree[i] += 1;
}
}
}
vector<int> depth(n, -1);
function<void (int, int)> dfs = [&](int i, int cur_depth) {
if (depth[i] < cur_depth) {
depth[i] = cur_depth;
for (int j : g[i]) {
dfs(j, cur_depth + 1);
}
}
};
repeat (i,n) if (indegree[i] == 0) {
dfs(i, 0);
}
int max_depth = *whole(max_element, depth);
printf("%d\n", max_depth + 1);
return 0;
}