結果

問題 No.3327 うるせぇ、ポリオミノぶつけんぞ
コンテスト
ユーザー tau1235
提出日時 2025-11-01 16:23:30
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 570 ms / 3,000 ms
+ 268µs
コード長 644 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,203 ms
コンパイル使用メモリ 340,296 KB
実行使用メモリ 9,872 KB
最終ジャッジ日時 2026-10-26 14:01:10
合計ジャッジ時間 15,109 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:34:15: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   34 |     cout<<ans+1<<endl;
      |               ^
main.cpp:25:9: note: 'ans' was declared here
   25 |     int ans;
      |         ^~~

ソースコード

diff #
raw source code

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

int inf=2e9;
int op(int a,int b){return max(a,b);}
int e(){return -inf;}
int x;
bool f(int a){return a<=x;}

int main(){
  int n,q;
  cin>>n>>q;
  vector<int> a(n);
  for (int i=0;i<n;i++) cin>>a[i];
  atcoder::segtree<int,op,e> seg(a);
  while (q--){
    int c;
    cin>>c>>x;
    int mx=seg.all_prod();
    if (mx<=x){
      cout<<-1<<endl;
      continue;
    }
    int ans;
    if (c==1){
      int idx=seg.max_right<f>(0);
      ans=idx;
    }
    if (c==2){
      int idx=seg.min_left<f>(n);
      ans=idx-1;
    }
    cout<<ans+1<<endl;
    seg.set(ans,e());
  }
}
0