Submission #2834987


Source Code Expand

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll int MOD=1e9+7;
#define INF 2*1e9
#define N 310000 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
ll int inv[N],comb[N];
void calc_inv(ll n){
    inv[1]=1;
    rep2(i,2,n*2){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}

main(){
    ll n;
    ll x,y;
    cin>>n>>x>>y;
    pii p[N];
    vector<pii> v;
    ll m=MOD;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        p[i].first=a;p[i].second=b;
        m=min(m,b);
        v.pb(p[i]);
    }
    sort(v.begin(),v.end());
    ll num[N]={};
    ll sum=0;
    rep2(i,1,n){
        int l=lower_bound(v.begin(),v.end(),(pii){i,0})-v.begin();
        int r=lower_bound(v.begin(),v.end(),(pii){i+1,0})-v.begin();
        ll t=v[l].second;
        rep2(j,l,r-1){
            if((t+v[j].second<=x&&t+m<=y)||v[j].second+m<=y)
            num[i]++;
        }
        sum+=num[i];
    }
    calc_inv(n);
    ll ans=1;
    for(ll i=1;i<=sum;i++){
        ans=(ans*i)%MOD;
    }
    rep2(i,1,n){
        rep2(j,1,num[i]) ans=(ans*inv[j])%MOD;
    }
    cout<<ans;
    
}

Submission Info

Submission Time
Task D - Colorful Balls
User noimi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1460 Byte
Status RE
Exec Time 293 ms
Memory 14444 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1000
Status
AC × 3
AC × 22
RE × 35
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 4 ms 9600 KB
00_example_02.txt AC 3 ms 9600 KB
00_example_03.txt AC 3 ms 9600 KB
01.txt AC 4 ms 9600 KB
02.txt AC 3 ms 9600 KB
03.txt AC 9 ms 9856 KB
04.txt AC 4 ms 9600 KB
05.txt AC 6 ms 9728 KB
06.txt AC 4 ms 9600 KB
07.txt AC 85 ms 11248 KB
08.txt AC 4 ms 9600 KB
09.txt AC 50 ms 10612 KB
10.txt AC 31 ms 10228 KB
11.txt AC 3 ms 9600 KB
12.txt AC 3 ms 9600 KB
13.txt AC 10 ms 9856 KB
14.txt AC 4 ms 9600 KB
15.txt AC 39 ms 10356 KB
16.txt AC 87 ms 11248 KB
17.txt AC 16 ms 9980 KB
18.txt AC 38 ms 10356 KB
19.txt AC 77 ms 11120 KB
20.txt RE 269 ms 13804 KB
21.txt RE 268 ms 14188 KB
22.txt RE 268 ms 13548 KB
23.txt RE 268 ms 13548 KB
24.txt RE 267 ms 13548 KB
25.txt RE 268 ms 13548 KB
26.txt RE 273 ms 13804 KB
27.txt RE 278 ms 14060 KB
28.txt RE 278 ms 13548 KB
29.txt RE 274 ms 13804 KB
30.txt RE 273 ms 13548 KB
31.txt RE 275 ms 13548 KB
32.txt RE 274 ms 13548 KB
33.txt RE 272 ms 13548 KB
34.txt RE 271 ms 13548 KB
35.txt RE 267 ms 13804 KB
36.txt RE 271 ms 14444 KB
37.txt RE 269 ms 14444 KB
38.txt RE 266 ms 13548 KB
39.txt RE 293 ms 13676 KB
40.txt RE 265 ms 13548 KB
41.txt RE 262 ms 14060 KB
42.txt RE 264 ms 13548 KB
43.txt RE 263 ms 13548 KB
44.txt RE 263 ms 13548 KB
45.txt RE 264 ms 14316 KB
46.txt RE 271 ms 13548 KB
47.txt RE 253 ms 13548 KB
48.txt RE 258 ms 13548 KB
49.txt RE 258 ms 13548 KB
50.txt RE 245 ms 13548 KB
51.txt RE 251 ms 14316 KB
52.txt RE 242 ms 14188 KB
53.txt RE 241 ms 13932 KB
54.txt RE 247 ms 14188 KB