QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#47480#4378. Ballzzxzzx123RE 0ms0kbC++171.3kb2022-09-10 10:30:202022-09-10 10:30:22

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-10 10:30:22]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2022-09-10 10:30:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200100;
vector<int>is_prime(N);
int solve(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>v(n);
    for( int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    vector<array<int,3>>vv;
    for( int i=0;i<n;i++){
        for( int j=i+1;j<n;j++){
            vv.push_back({abs(v[i].first-v[j].first)+abs(v[i].second-v[j].second),i,j});
        }
    }
    sort(vv.begin(),vv.end());
    vector<bitset<2000>>W(2000),B(2000);
    //W[i][j]表示从i到j的线段没有被访问过
    //B[i][j]表示从i到j的线段有被访问过
    for( int i=0;i<2000;i++){
        W[i].set();
    }   
    int ans=0; 
    for( int i=0;i<vv.size();i++){
        int x=vv[i][1],y=vv[i][2];
        if(!is_prime[vv[i][0]]) {
            ans+=(W[x]&B[y]).count()+(W[y]&B[x]).count();
        }
        W[x][y]=0;W[y][x]=0;
        B[x][y]=1;B[y][x]=1;
    }
    return ans;


    
}
int main(){
    is_prime[1]=1;
    for( int i=2;i<N;i++){
        if(is_prime[i]==0){
            for( int j=i+i;j<N;j+=i){
                is_prime[j]=1;
            }
        }
    }
    int t;
    cin>>t;
    while(t--){
        cout<<solve()<<"\n";
    }

    system("pause");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

10
2000 80
9 25
39 66
5 63
59 17
45 19
41 21
21 75
21 61
1 65
29 61
11 23
38 51
1 3
41 59
41 61
61 33
45 65
80 49
38 49
45 79
66 60
61 41
56 33
65 57
26 17
36 1
77 11
13 28
25 41
33 23
66 16
4 73
1 1
57 61
32 11
31 29
42 21
37 69
53 59
1 66
54 70
21 57
65 49
49 18
6 5
11 1
1 67
78 49
43 30
27 1
57 7...

output:

306097111
113711265
112644014
306052056
111920257
112598067
290930159
115277403
112743440

result: