Submission #00138
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int x,y; for ( int i=0;i<n;i++){ cin>>x>>y; int imax=0,imay=0,s=0; while (imax!=x||imay!=y){ if (imax-1>=x&&imay+1<=y){ imax--; imay++; s++; } else if (imax+1<=x&&imay-1>=y){ imax++; imay--; s++; } else if (imax+1<=x){ imax++; s++; } else if (imax-1>=x){ imax--; s++; } else if (imay+1<=y){ imay++; s++; } else if (imay-1>=y){ imay--; s++; } } cout<<s<<endl; } } |
ステータス
項目 | データ |
---|---|
問題 | 0007 - ハチの巣距離 |
ユーザー名 | e2403 |
投稿日時 | 2025-03-28 13:41:03 |
言語 | C++17 |
状態 | Accepted |
得点 | 30 |
ソースコード長 | 824 Byte |
最大実行時間 | 31 ms |
最大メモリ使用量 | 472 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 30 / 30 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
C1 | AC | 31 ms | 472 KB |
1
|
C2 | AC | 15 ms | 444 KB |
1
|
C3 | AC | 23 ms | 416 KB |
1
|
C4 | AC | 21 ms | 384 KB |
1
|