結果
問題 |
No.497 入れ子の箱
|
ユーザー |
![]() |
提出日時 | 2025-02-22 17:09:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 972 bytes |
コンパイル時間 | 1,600 ms |
コンパイル使用メモリ | 164,864 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-02-22 17:09:46 |
合計ジャッジ時間 | 3,066 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:20:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | freopen("box.in", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:21:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | freopen("box.out", "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; long long n; struct BOX { int x, y ,z; } box[10005]; vector<int> z[10005]; int dep[10005], in[10005], mx; void dfs(int x, int fa) { if(fa!=-1) dep[x] = max(dep[x], dep[fa]+1); for(auto i:z[x]) { if(i != fa) dfs(i, x); } } int main() { freopen("box.in", "r", stdin); freopen("box.out", "w", stdout); cin >> n; for(int i = 1; i <= n; i++) { cin >> box[i].x >> box[i].y >> box[i].z; int X=min({box[i].x,box[i].y,box[i].z}), Z=max({box[i].x,box[i].y,box[i].z}); int Y = box[i].x+box[i].y+box[i].z-X-Z; box[i].x = X; box[i].y = Y; box[i].z = Z; } for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(box[i].z > box[j].z && box[i].y > box[j].y && box[i].x > box[j].x) { z[i].push_back(j); in[j]++; } } } for(int i = 1; i <= n; i++) { if(!in[i]) { z[0].push_back(i); } } dfs(0, -1); for(int i = 1; i <= n; i++) { mx = max(mx, dep[i]); } cout << mx; }