結果
| 問題 |
No.497 入れ子の箱
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-22 16:52:36 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,055 bytes |
| コンパイル時間 | 3,449 ms |
| コンパイル使用メモリ | 277,708 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-02-22 16:52:47 |
| 合計ジャッジ時間 | 9,208 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 29 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
37 | freopen("box.in","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:38:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
38 | freopen("box.out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node{
int x,y,z;
}box[1010];
struct edge{
int to,next;
}a[1000010];
int head[1000010],cnt,ans;
bool f[1010];
void add(int u,int v)
{
a[++cnt].to=v;
a[cnt].next=head[u];
head[u]=cnt++;
}
bool cmp(node x,node y)
{
return x.x<y.x;
}
bool check(node x,node y)
{
if(x.x<y.x&&x.y<y.y&&x.z<y.z)
return 1;
return 0;
}
void dfs(int u,int tot)
{
f[u]=1;
ans=max(ans,tot);
for(int i=head[u];i;i=a[i].next)
dfs(a[i].to,tot+1);
}
signed main()
{
freopen("box.in","r",stdin);
freopen("box.out","w",stdout);
int n,x,y,z;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>box[i].x>>box[i].y>>box[i].z;
x=min(min(box[i].x,box[i].y),box[i].z);
z=max(max(box[i].x,box[i].y),box[i].z);
y=box[i].x+box[i].y+box[i].z-x-z;
box[i].x=x;
box[i].y=y;
box[i].z=z;
}
sort(box+1,box+n+1,cmp);
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
if(check(box[i],box[j]))
add(i,j);
}
}
for(int i=1;i<=n;i++)
{
if(!f[i])
dfs(i,1);
}
cout<<ans<<endl;
return 0;
}
vjudge1