結果

問題 No.3723 Climb or Detour
コンテスト
ユーザー cled0328
提出日時 2026-09-19 13:52:21
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 867 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,918 ms
コンパイル使用メモリ 353,140 KB
実行使用メモリ 10,000 KB
最終ジャッジ日時 2026-09-19 13:52:32
合計ジャッジ時間 6,711 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,k;cin>>n>>k;
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;sx--;sy--;tx--;ty--;
    int dis=abs(sx-tx)+abs(sy-ty);
    int mn=dis,mx=dis*2-dis%2;
    if(k<mn||k>mx||k%2!=dis%2){
        cout<<"-1\n";
        return 0;
    }
    int cnt=(k-mn)/2;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==sx&&j==sy||i==tx&&j==ty)cout<<".";
            else if((i+j)%2!=(sx+sy)%2){
                if(i==sx&&(j>sy&&j<ty||j>ty&&j<sy)||j==sy&&(i>sx&&i<tx||i>tx&&i<sx)){
                    if(cnt){
                        cout<<"#";
                        cnt--;
                    }else{
                        cout<<".";
                    }
                }else{
                    cout<<"#";
                }
            }else cout<<".";
        }
        cout<<endl;
    }
}
0