結果
| 問題 | 
                            No.5011 Better Mo's Algorithm is Needed!! (Weighted)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hotman78
                         | 
                    
| 提出日時 | 2022-12-23 16:46:53 | 
| 言語 | C++17(gcc12)  (gcc 12.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 351 ms / 5,000 ms | 
| コード長 | 863 bytes | 
| コンパイル時間 | 2,405 ms | 
| 実行使用メモリ | 12,192 KB | 
| スコア | 35,847,712,540 | 
| 最終ジャッジ日時 | 2022-12-23 16:48:29 | 
| 合計ジャッジ時間 | 84,254 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge15 / judge11 | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 120 | 
ソースコード
#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];
}
            
            
            
        
            
hotman78