結果

問題 No.3385 Up Down Hiking (C++)
コンテスト
ユーザー alcea
提出日時 2025-11-21 19:47:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 196,168 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-22 12:38:37
合計ジャッジ時間 8,383 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    1 | #import<bits/stdc++.h>
      |  ^~~~~~
main.cpp:3:27: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    3 | long n,h[4<<17],i,u,v,q,j;main(){for(;std::cin>>v;)n?h[i++]=(i-n)%2>0?h[u]<h[v]?:u^=v^=u^=v,h[u]*n*n+u*n+v:u=v:n=v+1;std::sort(h+1,++i+h);h[1]=h[i+n-1]=4*n+1;for(j=*h-~n;v=h[j++];)c(q,c(h[v%n],h[u=v/n%n]+1)+c(h[v%n+i],h[u+i]+1)-8*n);printf("%d\n",q-1);}
      |                           ^~~~
main.cpp: In function ‘int main()’:
main.cpp:3:243: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
    3 | long n,h[4<<17],i,u,v,q,j;main(){for(;std::cin>>v;)n?h[i++]=(i-n)%2>0?h[u]<h[v]?:u^=v^=u^=v,h[u]*n*n+u*n+v:u=v:n=v+1;std::sort(h+1,++i+h);h[1]=h[i+n-1]=4*n+1;for(j=*h-~n;v=h[j++];)c(q,c(h[v%n],h[u=v/n%n]+1)+c(h[v%n+i],h[u+i]+1)-8*n);printf("%d\n",q-1);}
      |                                                                                                                                                                                                                                                  ~^    ~~~
      |                                                                                                                                                                                                                                                   |     |
      |                                                                                                                                                                                                                                                   int   long int
      |                                                                                                                                                                                                                                                  %ld

ソースコード

diff #
raw source code

#import<bits/stdc++.h>
#define c(a,b)(a=a>b?a:b)
long n,h[4<<17],i,u,v,q,j;main(){for(;std::cin>>v;)n?h[i++]=(i-n)%2>0?h[u]<h[v]?:u^=v^=u^=v,h[u]*n*n+u*n+v:u=v:n=v+1;std::sort(h+1,++i+h);h[1]=h[i+n-1]=4*n+1;for(j=*h-~n;v=h[j++];)c(q,c(h[v%n],h[u=v/n%n]+1)+c(h[v%n+i],h[u+i]+1)-8*n);printf("%d\n",q-1);}
0