提出 #55079217


ソースコード 拡げる

#include"bits/stdc++.h"
using namespace std;

typedef  long long ll;
typedef long double ld;
 
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag,
         tree_order_statistics_node_update>
is;*/
 
#define fb find_by_order
#define ok order_of_key
 
#define mem(x,y) memset(x,y,sizeof x)
 
typedef pair<ll,ll> pi;
typedef vector<pair<ll,ll>> vii;
 
#define map unordered_map
 
#define pi1 3.141592654
 
typedef unsigned long long ull;
 
#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for1(i,a,b) for(i=a;i<=b;i=i+1)
 
#define pb push_back
#define pf push_front
 
#define ff first
#define ss second
 
#define mp midpoint
 
#define pre starts_with
#define suf ends_with
 
typedef vector<ll> vi;
 
#define clz __builtin_clzll
#define ctz __builtin_ctzll
#define popcount __builtin_popcountll
#define parity __builtin_parityll
 
#define all(v) sort(v.begin(),v.end())
#define all1(v) sort(v.rbegin(),v.rend())
 
#define sorted(v) is_sorted(v.begin(),v.end())
#define sorted1(v) is_sorted(v.begin(),v.end())

struct boost{
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
template <class K, class V> using um = unordered_map <K, V, boost>;

ll INF;

auto rup = [](ll ik, ll ikk) {
  return (ik + ikk - 1) / ikk;
};

auto nm=[](ll a,ll b){
  
  
  return (b + (a%b)) % b;
  
};


ll modpow(ll x1, ll n1, ll m1) {
  if (n1 == 0) return 1%m1;
  long long u1 = modpow(x1,n1/2,m1);
  u1 = (u1*u1)%m1;
  if (n1%2 == 1) u1 = (u1*x1)%m1;
  return u1;
  
}



int main(){
 
   ios::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

    INF=1000000007;
    ll t=1;
    
    //cin>>t;
    
    mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());


    ll x[200002];

    while(t--){
         
      ll b,n;
      cin>>n>>b;
      
      string s;
      cin>>s;
      ll i;
      
      vi v;
      vi v2;
      
      for(ll i=1;i<=n;i++){
        
           cin>>x[i];
           if(s[i-1]=='1') v.pb(x[i]);
            else v2.pb(x[i]);
        
        
      }
      
      ll ans=0;
      
      all(v2);
      
      for(auto u : v){
        
        
         ll aa=u;
          ll bb=u+(b*2);
      
         ll cc=INF;
          
          ll l=0;
          ll r=v2.size();
          r--;
          
        while(l<=r){
          
           ll mid=midpoint(l,r);
        
          if(v2[mid]>=aa){
            
              cc=mid;
              r=mid-1;
                
            
          }
          else l=mid+1;
          
          
        }
          
        if(cc!=INF){
          
          l=cc;
          r=v2.size();
          r--;
        
          ll dd=cc;
        
          while(l<=r){
            
            ll mid=midpoint(l,r);
            
            if(v2[mid]<=bb){
              
              dd=mid;
              l=mid+1;
              
              
            }
            else r=mid-1;
            
            
          }        
        
        
          ans+=dd-cc+1;
        
          
        }
        
        
        
        
        
      }
      
      cout<<ans<<"\n";
      
      
      
  
    }
  

        
 
 
}

提出情報

提出日時
問題 D - Ghost Ants
ユーザ turzo_sawroop
言語 C++ 20 (gcc 12.2)
得点 0
コード長 3816 Byte
結果 WA
実行時間 40 ms
メモリ 7360 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:121:10: warning: unused variable ‘i’ [-Wunused-variable]
  121 |       ll i;
      |          ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 350
結果
AC × 2
AC × 26
WA × 2
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 5016 KiB
00_sample_01.txt AC 1 ms 5072 KiB
01_random_00.txt AC 36 ms 6640 KiB
01_random_01.txt AC 22 ms 5984 KiB
01_random_02.txt AC 39 ms 6724 KiB
01_random_03.txt AC 30 ms 6380 KiB
01_random_04.txt AC 37 ms 6916 KiB
01_random_05.txt AC 18 ms 6092 KiB
01_random_06.txt AC 38 ms 6980 KiB
01_random_07.txt AC 30 ms 6428 KiB
01_random_08.txt AC 34 ms 6852 KiB
01_random_09.txt AC 33 ms 6452 KiB
01_random_10.txt AC 40 ms 6716 KiB
01_random_11.txt AC 36 ms 6608 KiB
01_random_12.txt AC 40 ms 6788 KiB
01_random_13.txt AC 29 ms 6584 KiB
01_random_14.txt AC 36 ms 6964 KiB
01_random_15.txt AC 19 ms 6056 KiB
01_random_16.txt AC 37 ms 6884 KiB
01_random_17.txt AC 26 ms 6568 KiB
01_random_18.txt AC 38 ms 6640 KiB
01_random_19.txt AC 29 ms 6608 KiB
01_random_20.txt AC 17 ms 7212 KiB
01_random_21.txt AC 18 ms 7272 KiB
01_random_22.txt WA 19 ms 7276 KiB
01_random_23.txt AC 20 ms 7360 KiB
01_random_24.txt WA 21 ms 6880 KiB
01_random_25.txt AC 22 ms 6880 KiB