QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#412343 | #8669. 正方形计数 | ANIG | 15 | 7ms | 3680kb | C++14 | 1.2kb | 2024-05-16 12:05:35 | 2024-05-16 12:05:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=15;
const int inf=1e18;
int n,mnx=inf,mny=inf,mxx=-inf,mxy=-inf,res,x[N],y[N];
double S,eps=1e-5;
double gets(double a,double b,double c){
double k=(a+b+c)/2;
return sqrtl(k*(k-a)*(k-b)*(k-c));
}
double d(int x1,int y1,int x2,int y2){
return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
bool in(int xx,int xy){
double ans=0;
for(int i=2;i<=n;i++){
ans+=gets(d(xx,xy,x[i-1],y[i-1]),d(xx,xy,x[i],y[i]),d(x[i-1],y[i-1],x[i],y[i]));
}
ans+=gets(d(xx,xy,x[1],y[1]),d(xx,xy,x[n],y[n]),d(x[1],y[1],x[n],y[n]));
return abs(ans-S)<=eps;
}
signed main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>x[i]>>y[i];
}
for(int i=3;i<=n;i++){
S+=gets(d(x[1],y[1],x[i],y[i]),d(x[1],y[1],x[i-1],y[i-1]),d(x[i],y[i],x[i-1],y[i-1]));
}
int res=0;
for(int i=0;i<=20;i++){
for(int j=0;j<=20;j++){
for(int k=0;k<i;k++){
for(int t=j+1;t<=20;t++){
int a=t-j,b=i-k;
if(in(i,j)&&in(k,t)&&in(i-a,j-b)&&in(k-a,t-b))res++;
}
}
for(int k=i-1;k>=0;k--){
int a=i-k;
if(in(k,j-a)&&in(i,j)&&in(k,j)&&in(i,j-a))res++;
}
// cout<<i<<" "<<j<<" "<<in(i,j)<<endl;
}
}
cout<<res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3596kb
input:
4 131 603 131 1828 1919 1828 1919 603
output:
0
result:
wrong answer 1st numbers differ - expected: '361182910200', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 2ms
memory: 3600kb
input:
3 131 603 131 1828 1919 603
output:
0
result:
wrong answer 1st numbers differ - expected: '63739309181', found: '0'
Subtask #3:
score: 15
Accepted
Test #11:
score: 15
Accepted
time: 7ms
memory: 3616kb
input:
8 0 13 4 15 15 15 15 6 13 1 12 0 5 0 0 6
output:
4047
result:
ok 1 number(s): "4047"
Test #12:
score: 0
Accepted
time: 7ms
memory: 3656kb
input:
8 0 4 1 15 2 15 15 14 15 4 14 0 1 0 0 2
output:
4200
result:
ok 1 number(s): "4200"
Test #13:
score: 0
Accepted
time: 5ms
memory: 3488kb
input:
5 7 15 15 13 15 0 3 0 0 15
output:
3635
result:
ok 1 number(s): "3635"
Test #14:
score: 0
Accepted
time: 7ms
memory: 3680kb
input:
8 0 12 2 14 7 15 13 15 15 10 15 1 8 0 0 0
output:
4511
result:
ok 1 number(s): "4511"
Test #15:
score: 0
Accepted
time: 5ms
memory: 3552kb
input:
6 0 11 3 15 7 15 15 12 10 0 0 0
output:
3006
result:
ok 1 number(s): "3006"
Test #16:
score: 0
Accepted
time: 3ms
memory: 3676kb
input:
5 0 0 0 2 1 2 2 1 2 0
output:
4
result:
ok 1 number(s): "4"
Subtask #4:
score: 0
Wrong Answer
Dependency #3:
100%
Accepted
Test #17:
score: 0
Wrong Answer
time: 2ms
memory: 3488kb
input:
8 49 299 144 300 300 260 250 15 115 0 30 0 23 19 0 85
output:
0
result:
wrong answer 1st numbers differ - expected: '443602646', found: '0'
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%