# HDOJ(2150) 我的哪错了？C++提交的。跪求代码！！！

0

```#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

struct Node
{
int x,y;
Node operator-(Node &node)
{
Node new_node;
new_node.x=x-node.x;
new_node.y=y-node.y;
return new_node;
}
};
vector<vector<Node> > L;
double cross(Node vec1,Node vec2)
{
return (double)vec1.x*vec2.y-(double)vec1.y*vec2.x;
}
bool straddle(Node n1,Node n2,Node n3,Node n4)
{
Node vec1=n2-n1;
Node vec2=n3-n2;
Node vec3=n4-n2;
if(cross(vec1,vec2)*cross(vec1,vec3)<=0)
return true;
else
return false;
}
double special_straddle(Node n1,Node n2,Node n3,Node n4)
{
Node vec1=n2-n1;
Node vec2=n3-n2;
Node vec3=n4-n2;
return cross(vec1,vec2)*cross(vec1,vec3);
}
bool intersect(vector<vector<Node> > L)
{
int len=L.size();
for(int i=0;i<len-1;i++)
{
for(int m=0;m<L[i].size()-1;m++)
{
for(int j=i+1;j<len;j++)
{
for(int n=0;n<L[j].size()-1;n++)
{
if((m==0&&cross(L[j][n]-L[i][m],L[j][n]-L[j][n+1])==0)||
(m==L[i].size()-2&&cross(L[j][n]-L[i][m+1],L[j][n]-L[j][n+1])==0)||
(n==0&&cross(L[i][m]-L[j][n],L[i][m]-L[i][m+1])==0)||
(n==L[i].size()-2&&cross(L[i][m]-L[j][n+1],L[i][m]-L[i][m+1])==0))
continue;

return true;
}
}
}

}
return false;
}
int main()
{
int num,n; //num为管道数，n为每条管道的端点数
vector<Node> p;
while(scanf("%d",&num)!=EOF)
{
L.clear();
Node temp;
for(int i=0;i<num;i++)
{
p.clear();
cin>>n;
for(int j=0;j<n;j++)
{
cin>>temp.x>>temp.y;
p.push_back(temp);
}
L.push_back(p);
}
if(num<=1)
{
cout<<"NO"<<endl;
continue;
}
if(intersect(L))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}```
Chiryen | 初学一级 | 园豆：194

0

Chiryen | 园豆：194 (初学一级) | 2014-01-08 13:31
0

wtu_sos | 园豆：181 (初学一级) | 2014-03-16 10:13

HDOJ上的题目总是Wrong，已经解决了，呵呵

您需要登录以后才能回答，未注册用户请先注册