当前位置:网站首页>CCF 1-2 question answering record (1)
CCF 1-2 question answering record (1)
2022-07-24 11:41:00 【I can't understand your code】
It's called checkpoint query
//#include <bits/stdc++.h> // Submitted to the CCF Need to add universal header file
#include <iostream>
#include <math.h>
using namespace std;
struct PointD{
int PointN;
double D;
struct PointD* next;
};
int main(){
int x,y,n,xi,yi;
double distance;
struct PointD* p=new struct PointD;
struct PointD* head=p;
struct PointD* preP;
scanf("%d %d %d",&n,&x,&y);
for(int i=0;i<n;++i){
scanf("%d %d",&xi,&yi);
distance=(sqrt(pow(xi-x,2)+pow(yi-y,2)));
p->PointN=i+1;
p->D=distance;
preP=p;
p=p->next=new struct PointD;
}
preP->next=NULL;
//sorting
struct PointD* pre=new struct PointD;
pre->next=head;
for(int i=0;i<3;++i){
int minN=pre->next->PointN;
double minD=pre->next->D;
struct PointD* preMin=pre;
for(struct PointD* temp=pre;temp->next->next;temp=temp->next){
if(temp->next->D < minD){
minN=temp->next->PointN;
minD=temp->next->D;
preMin=temp;
}
else if(temp->next->D == minD){
if(temp->next->PointN < minN){
minN=temp->next->PointN;
minD=temp->next->D;
preMin=temp;
}
}
}
struct PointD* f=preMin->next;
preMin->next=preMin->next->next;
free(f);
cout<<minN<<endl;
}
return 0;
}Screening for people at risk
#include <bits/stdc++.h>
using namespace std;
//boolean: check the point stands in the square or not
bool examine(int xl,int yd,int xr,int yu,int xi,int yi){
if(xi>=xl && yi>=yd && xi<=xr && yi<=yu){
return 1;
}
else{
return 0;
}
}
int main(){
int n,k,t,xl,yd,xr,yu,x,xi,yi;
int whether;int stay=0;int passBy=0;
scanf("%d %d %d %d %d %d %d",&n,&k,&t,&xl,&yd,&xr,&yu);
for(int i=0;i<n;i++){
vector<int> point;
int sum=0;int continuous=0;int isStay=0;
for(int j=0;j<(2*t);j++){
cin>>x;
point.push_back(x);
}
for(int i=0;i<(2*t-1);i=i+2){
xi=point[i];
yi=point[i+1];
//cout<<"xi: "<<xi<<" yi: "<<yi<<endl;
whether=examine(xl,yd,xr,yu,xi,yi);
//cout<<"whether: "<<whether<<endl;
sum += whether;
//cout<<"sum: "<<sum<<endl;
if(whether){
continuous++;
if(continuous>=k){
isStay=1;
}
}
else{
continuous=0;
}
}
if(isStay){
stay++;
//cout<<"stay: "<<stay<<endl;
}
//cout<<"cintinuous: "<<continuous<<endl;
//cout<<"isStay: "<<isStay<<endl;
if(sum>=1){
passBy++;
//cout<<"passBy: "<<passBy<<endl;
}
}
cout<<passBy<<endl;
cout<<stay;
return 0;
}Safety index of final forecast
#include <iostream>
#include <math.h>
using namespace std;
int main(){
int n,wi,scorei,sum=0;
cin>>n;
if(n<2 || n>pow(10,5)){
return 0;
}
for(int i=0;i<n;i++){
scanf("%d %d",&wi,&scorei);
sum+=wi*scorei;
}
int y=max(0,sum);
cout<<y;
return 0;
}The best threshold of final forecast
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main(){
int m; // row
cin>>m;
if(m<2 || m>pow(10,5)){
return 0;
}
vector<int> y;
vector<int> result;
int yi,resulti;
for(int i=0;i<m;++i){
scanf("%d %d",&yi,&resulti);
y.push_back(yi);
result.push_back(resulti);
}
vector<int> B(m);
set<int> temp(y.begin(),y.end());
B.assign(temp.begin(),temp.end());
vector<int> sum(B.size(),0);
for(int i=0;i<B.size();i++){
for(int j=0;j<m;j++){
sum[i] += (y[j]>=B[i] == result[j]);
}
//cout<<sum[i]<<endl; //debug
}
vector<int> sum_sort=sum;
sort(sum_sort.begin(),sum_sort.end());
int sum_max=sum_sort.back();
vector<int> num;
for(int i=0;i<B.size();++i){
if(sum[i]==sum_max){
num.push_back(i);
}
}
/*for(int i=0;i<num.size();i++){
cout<<num[i]<<endl;
}*/
sort(num.begin(),num.end());
int B_best=num.back();
cout<<B[B_best];
return 0;
}
边栏推荐
- Hcip OSPF interface network type experiment day 4
- Semaphore details
- MySql的DDL和DML和DQL的基本语法
- HCIP MGRE实验 第三天
- Notes on @enableconfigurationproperties
- [golang] golang implements MD5 encryption function
- Jmeter-Runtime控制器
- Imeta view | is short reading long amplicon sequencing applicable to the prediction of microbiome function?
- Judge whether a group of cards can become shunzi (the size of the king is 14,15)
- Jmeter-While控制器
猜你喜欢
随机推荐
Nodejs ctf 基础
08 [AIO programming]
Notes on @enableconfigurationproperties
Leetcode 112. 路径总和
JMeter runtime controller
Sorting out the ideas of data processing received by TCP server, and the note of select: invalid argument error
A*与JPS
Semaphore详解
Basic syntax of MySQL DDL and DML and DQL
Nodejs CTF Foundation
[golang] golang implements the string interception function substr
Types and history of bugs in it circle
[TA frost wolf umay - "hundred people plan] Figure 3.3 surface subdivision and geometric shader large-scale grass rendering
An analysis of the CPU surge of an RFID tag management system in.Net
[QNX hypervisor 2.2 user manual]9.2 CmdLine
哈希——202. 快乐数
Stream stream
Performance test summary (I) -- basic theory
How to access the code of online customer service system to your website
Easy to use example







