結果

問題 No.3327 うるせぇ、ポリオミノぶつけんぞ
コンテスト
ユーザー tau1235
提出日時 2025-11-01 16:23:30
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 549 ms / 3,000 ms
コード長 644 bytes
コンパイル時間 3,668 ms
コンパイル使用メモリ 281,756 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-01 16:23:45
合計ジャッジ時間 12,665 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

#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