Submission #72711804


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int N = 1e6+10;

int n,q;

ll a[N],b[N];
int id[N];
map<long double,int> mp;
vector<long double> vd;
ll sum[N];
int main() {
    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    vector<pair<long double,int>> v;
    for(int i=1;i<=n;i++) {
        long double jijiao=atan2l(b[i],a[i]);
        v.push_back({jijiao,i});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++) {
        if(i==0||v[i].first!=v[i-1].first) vd.push_back(v[i].first);
        sum[vd.size()]++;
        id[v[i].second]=vd.size();
    }
    for(int i=0;i<vd.size();i++) {
        sum[i+1+vd.size()]=sum[i+1];
    }
    for(int i=1;i<N;i++) sum[i]+=sum[i-1];
    while(q--) {
        int x,y;
        cin>>x>>y;
        int id1=id[x],id2=id[y];
        if(id1==id2) {
            cout<<sum[id2]-sum[id1-1]<<"\n";
            continue;
        }
        if(id2<id1) id2+=vd.size();
        id1++,id2--;
        ll res=0;
        if(id1<=id2) res=sum[id2]-sum[id1-1];
        cout<<n-res<<"\n";
    }

}

Submission Info

Submission Time
Task E - Laser Takahashi
User zhishengie
Language C++23 (GCC 15.2.0)
Score 450
Code Size 1118 Byte
Status AC
Exec Time 289 ms
Memory 28588 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0;i<v.size();i++) {
      |                 ~^~~~~~~~~
./Main.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<vd.size();i++) {
      |                 ~^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 33
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.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, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 05_killer_00.txt, 05_killer_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 5 ms 11400 KiB
00_sample_01.txt AC 5 ms 11384 KiB
00_sample_02.txt AC 5 ms 11384 KiB
01_random_00.txt AC 144 ms 15240 KiB
01_random_01.txt AC 217 ms 28196 KiB
01_random_02.txt AC 239 ms 26940 KiB
01_random_03.txt AC 17 ms 12080 KiB
01_random_04.txt AC 230 ms 28560 KiB
01_random_05.txt AC 286 ms 28584 KiB
01_random_06.txt AC 284 ms 28576 KiB
01_random_07.txt AC 285 ms 28588 KiB
01_random_08.txt AC 284 ms 28496 KiB
01_random_09.txt AC 283 ms 28512 KiB
02_random2_00.txt AC 284 ms 28204 KiB
02_random2_01.txt AC 284 ms 28200 KiB
02_random2_02.txt AC 283 ms 28116 KiB
02_random2_03.txt AC 282 ms 28260 KiB
02_random2_04.txt AC 283 ms 28028 KiB
02_random2_05.txt AC 284 ms 28140 KiB
02_random2_06.txt AC 288 ms 28116 KiB
02_random2_07.txt AC 286 ms 28176 KiB
02_random2_08.txt AC 283 ms 28184 KiB
02_random2_09.txt AC 283 ms 28180 KiB
03_random3_00.txt AC 276 ms 27864 KiB
03_random3_01.txt AC 269 ms 25248 KiB
03_random3_02.txt AC 261 ms 24588 KiB
03_random3_03.txt AC 250 ms 22952 KiB
03_random3_04.txt AC 240 ms 21356 KiB
04_handmade_00.txt AC 208 ms 21432 KiB
04_handmade_01.txt AC 206 ms 21352 KiB
04_handmade_02.txt AC 116 ms 11356 KiB
05_killer_00.txt AC 281 ms 28240 KiB
05_killer_01.txt AC 289 ms 28112 KiB