結果

問題 No.5010 Better Mo's Algorithm is Needed!! (Unweighted)
ユーザー hotman78
提出日時 2022-12-23 16:51:45
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 381 ms / 5,000 ms
コード長 863 bytes
コンパイル時間 2,241 ms
実行使用メモリ 12,376 KB
スコア 15,721,423,400
最終ジャッジ日時 2022-12-23 16:53:20
合計ジャッジ時間 92,055 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 120
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(n) (n).begin(),(n).end()
using lint=long long;
constexpr __int128_t maxn = __int128_t(1) << 100;
__int128_t hilbertorder(__int128_t x, __int128_t y) {
  __int128_t rx, ry, d = 0;
  for (__int128_t s=maxn>>1; s; s>>=1) {
    rx = (x & s)>0, ry = (y & s)>0;
    d += s * s * ((rx * 3) ^ ry);
    if (ry) continue;
    if (rx) {
      x = maxn-1 - x;
      y = maxn-1 - y;
    }
    swap(x, y);
  }
  return d;
}



int main(){
	lint n,q,wt,st;
	cin>>n>>q>>wt>>st;
    vector<lint>w(n),ws(n+1);
    rep(i,0,n)cin>>w[i];
    rep(i,0,n)ws[i+1]+=ws[i]+w[i];
    vector<pair<lint,int>>v;
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        v.emplace_back(hilbertorder(ws[x],ws[y]),i);
    }
    sort(all(v));
    rep(i,0,n)cout<<v[i].second+1<<" \n"[i==n-1];
}
0