結果

問題 No.3745 Line Seats
ユーザー Nihonielse
提出日時 2026-08-27 21:04:33
言語 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  
(最新)
AC  
(最初)
実行時間 -
コード長 927 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,154 ms
コンパイル使用メモリ 355,220 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-09-23 12:30:17
合計ジャッジ時間 6,366 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
部分点 20 % AC * 10 WA * 32 RE * 5
満点 80 % AC * 10 WA * 32 RE * 18
合計 2 * 0% = 0 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define  rep(i,n)   for(int i=0; i<n; i++)

constexpr int INF = 1<<30;

template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main(){
    int n,x;string s;
    cin>>n>>x>>s;
    vector<int> dist(n,10000000);
    int now=-1;
    rep(i,n){
        if(s[i]=='#')now=0;
        if(now>=0){
            dist[i]=now;
        }
        now++;
    }
    now=-1;
    rep(i,n){
        if(s[n-i-1]=='#')now=0;
        if(now>=0){
            chmin(dist[n-i-1],now);
        }
        now++;
    }
    int ans=0;
    now=-1;
    rep(i,n){
        if(chmax(now,dist[i])){
            ans=i+1;
        }else if(now==dist[i]){
            if(abs(ans-x)>abs(i+1-x))ans=i+1;
        }
    }
    cout<<ans;
}
0