結果
| 問題 | No.3745 Line Seats |
| ユーザー |
|
| 提出日時 | 2026-08-27 20:58:51 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 933 bytes |
| 記録 | |
| コンパイル時間 | 4,699 ms |
| コンパイル使用メモリ | 355,364 KB |
| 実行使用メモリ | 9,928 KB |
| 最終ジャッジ日時 | 2026-09-23 12:30:10 |
| 合計ジャッジ時間 | 9,154 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点 | 20 % | AC * 9 WA * 33 RE * 5 |
| 満点 | 80 % | AC * 9 WA * 33 RE * 18 |
| 合計 | 2 * 0% = 0 点 |
ソースコード
#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<<endl;
}