i-Curve 2018-09-14 09:14 采纳率: 0%
浏览 408

codeforces1036e题怎么运行错了啊

问题描述:我是linux系统,自己电脑上能跑正确答案,在线测试也是正确,但是提交后第一个样列就错.这是我的代码

#include
#define endl '\n'
#define pb push_back
#define mk make_pair
#define _ ios::sync_with_stdio(false)
bool SUBMIT = 1;
typedef long long ll;
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-10;
double add(double a,double b){
if(abs(a+b) return a+b;
}
struct node
{
double x,y;
node(){};
node(double x,double y):x(x),y(y){}
bool operator return x!=b.x?x }
node operator +(node b){
return node(add(x,b.x),add(y,b.y));
}
node operator -(node b){
return node(add(x,-b.x),add(y,-b.y));
}
node operator *(double b){
return node(x*b,y*b);
}
double dot(node b){//neiji
return add(x*b.x,y*b.y);
}
double det(node b){//waiji
add(x*b.y,-y*b.x);
}
}s1[1100],s2[1100];
int n,check[105];
maph;
bool on_seg(node p1,node p2,node q){//panduanshifouzaixianduanshang
return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;
}
node interel(node p1,node p2,node q1,node q2){//zhaochujiaodian
return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));
}
bool on_check(int k){
int l=3,r=105;
while(r-l>1){
int mid=(l+r)/2;
if(k>=check[mid])l=mid;
else r=mid;
}
if(k==check[l])return true;
return false;
}
int main()
{
if(!SUBMIT)freopen("i.txt","r",stdin);else ;
for(int i=3;i cin>>n;
for(int i=0;i>s1[i].x>>s1[i].y>>s2[i].x>>s2[i].y;
int ans=0;
for(int i=0;i<n;i++)
{
node k=s1[i]-s2[i];int c;
if(!k.x||!k.y)c=max(abs((int)k.x),abs((int)k.y));
else c=
_gcd(abs((int)k.x),abs((int)k.y));
ans+=c+1;
}
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
{
node a=s1[i]-s2[i],b=s1[j]-s2[j];
if(a.det(b)==0){
continue;
}
node m=interel(s1[i],s2[i],s1[j],s2[j]);
m.x=round(m.x);m.y=round(m.y);
if(on_seg(s1[i],s2[i],m)&&on_seg(s1[j],s2[j],m)){
h[m]++;
if(!on_check(h[m]))ans--;
}
}
cout<<ans<<endl;
return 0;
}

第一组样列:
9
0 0 4 4
-1 5 4 0
4 0 4 4
5 2 11 2
6 1 6 7
5 6 11 6
10 1 10 7
7 0 9 8
10 -1 11 -1
正确答案:42
我提交后答案:49
我电脑答案:42

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-08-07 05:18
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    你的代码在运行时出现了错误。首先,请检查代码中是否有语法错误。其次,代码中的 SUBMIT 变量应该是 #define SUBMIT

    此外,你提到的代码中使用了 long long 类型和 double 类型,但没有进行类型转换。这可能导致编译器或解释器无法正确解析这些变量。

    最后,你需要确保你的输入数据是有效的,并且满足题目要求。例如,题目要求计算所有不重叠交集的数量,但是在你的代码中计算的是所有交集数量。

    评论

报告相同问题?