結果
問題 | No.966 引き算をして門松列(その1) |
ユーザー |
![]() |
提出日時 | 2020-01-13 20:37:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 979 bytes |
コンパイル時間 | 3,658 ms |
コンパイル使用メモリ | 192,188 KB |
最終ジャッジ日時 | 2025-01-08 17:32:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 1000000009 int main(){ int T; cin>>T; for(int i=0;i<T;i++){ int A,B,C; cin>>A>>B>>C; if(A>B&&C>B){ if(A==C){ if(B+1==A){ if(B==1)cout<<-1<<endl; else cout<<2<<endl; } else{ cout<<1<<endl; } } else{ cout<<0<<endl; } continue; } if(A<B&&C<B){ if(A==C){ if(A==1)cout<<-1<<endl; else cout<<1<<endl; } else{ cout<<0<<endl; } continue; } if(A>C)swap(A,C); int ans = 0; int x = 0; if(A==B){ ans++; x++; if(A==C){ ans+=2; x++; } if(B-x<=0)ans = -1; } else if(B==C){ ans++; x++; if(C-1==A){ ans++; x++; } if(C-x<=0)ans = -1; } else{ ans = Inf; if(A!=1)ans = min(ans,B-A+1); if(B-A!=1)ans = min(ans,C-B+1); if(ans==Inf)ans = -1; } cout<<ans<<endl; } return 0; }