QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465921 | #8468. Collinear Arrangements | lam | Compile Error | / | / | C++14 | 3.4kb | 2024-07-07 13:46:53 | 2024-07-07 13:46:53 |
Judging History
This is the latest submission verdict.
- [2024-07-07 13:46:53]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-07-07 13:46:53]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define int long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
if(nega==-1) return -ans;
return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 200005
struct Vec
{
int x,y;
Vec(int a=0,int b=0) {x=a,y=b;}
};
Vec operator + (const Vec &x,const Vec &y) {return Vec(x.x+y.x,x.y+y.y);}
Vec operator - (const Vec &x,const Vec &y) {return Vec(x.x-y.x,x.y-y.y);}
Vec operator * (const Vec &x,const int y) {return Vec(x.x*y,x.y*y);}
Vec operator / (const Vec &x,const int y) {return Vec(x.x/y,x.y/y);}
int cdot(const Vec &x,const Vec &y) {return x.x*y.x+x.y*y.y;}
int cross(const Vec &x,const Vec &y) {return x.x*y.y-x.y*y.x;}
int norm(Vec x) {return x.x*x.x+x.y*x.y;}
Vec rot90(Vec x) {return Vec(x.y,-x.x);}
Vec a[N];
int n,QQ;
signed main()
{
cin>>n>>QQ;
for(int i=1;i<=n;i++) a[i].x=read(),a[i].y=read(),a[i+n]=a[i];
a[n+n+1]=a[1];
while(QQ--)
{
int op=read();
if(op==2)
{
Vec P,Q;
P.x=read(),P.y=read();
Q.x=read(),Q.y=read();
Vec v=rot90(Q-P);
int orig=1;
while(cdot(a[orig+1]-a[orig],v)==0) orig++;
int c1=orig;
if(cdot(a[c1+1]-a[c1],v)<0) v=v*(-1);
// printf("%d %d\n",v.x,v.y);
for(int i=17;i>=0;i--)
{
if(c1+(1<<i)<=orig+n-1)
{
int tw=c1+(1<<i);
if(cdot(v,a[tw+1]-a[tw])>0&&cdot(v,a[tw]-a[c1])>=0) c1+=(1<<i);
}
}
auto find=[&](int l,int r)->int
{
int o=cross(Q-P,a[l]-P);
if(o==0) return 1;
while(l<=r)
{
int mid=(l+r)/2;
int tw=cross(Q-P,a[mid]-P);
if(tw==0) return 1;
if((tw>0)==(o>0)) l=mid+1;
else r=mid-1;
}
return 0;
};
int ans=0;
ans+=find(orig+1,c1);
ans+=find(c1+1,orig+n);
cout<<orig<<‘ ‘<<c1<<‘\n’;
printf("%lld\n",ans);
}
else
{
Vec P;
P.x=read(),P.y=read();
int siz1=0,siz2=0;
for(int i=1;i<=n;i++) siz1+=abs(cross(a[i+1]-P,a[i]-P));
for(int i=2;i+1<=n;i++) siz2+=abs(cross(a[i+1]-a[1],a[i]-a[1]));
// printf("%d %d\n",siz1,siz2);
if(siz1==siz2)
{
int ans=0,j=1;
for(int i=1;i<=n;i++)
{
while(i==j||cross(a[i]-P,a[j]-P)>0) j++;
// printf("%d %d %d\n",i,j,cross(a[i]-P,a[j]-P));
if(cross(a[i]-P,a[j]-P)==0) ans++;
}
printf("%d\n",ans/2);
}
else
{
int l=1,r=1;
for(int i=2;i<=n;i++)
{
if(cross(P-a[l],P-a[i])>0 || (cross(P-a[l],P-a[i])==0&&norm(P-a[i])>norm(P-a[l]))) l=i;
if(cross(P-a[r],P-a[i])<0 || (cross(P-a[r],P-a[i])==0&&norm(P-a[i])>norm(P-a[r]))) r=i;
}
swap(l,r);
// printf("%d %d\n",l,r);
int cl=l,cr=l-1+n,ans=0;
if((r+1)%n==l%n) {}
else
{
while(1)
{
if(cross(P-a[cl],P-a[cr])==0) ans++;
// printf("* %d %d\n",cl,cr);
if(cl%n==r%n&&cr%n==(r+1)%n) break;
if(cl%n==r%n) cr--;
else if(cr%n==(r+1)%n) cl++;
else
{
if(cross(P-a[cl],P-a[cr])>0) cl++;
else cr--;
}
}
}
printf("%d\n",ans);
}
}
}
return 0;
}
Details
answer.code:80:13: error: extended character ‘ is not valid in an identifier 80 | cout<<orig<<‘ ‘<<c1<<‘\n’; | ^ answer.code:80:15: error: extended character ‘ is not valid in an identifier 80 | cout<<orig<<‘ ‘<<c1<<‘\n’; | ^ answer.code:80:22: error: extended character ‘ is not valid in an identifier 80 | cout<<orig<<‘ ‘<<c1<<‘\n’; | ^ answer.code:80:23: error: stray ‘\’ in program 80 | cout<<orig<<‘ ‘<<c1<<‘\n’; | ^ answer.code:80:24: error: extended character ’ is not valid in an identifier 80 | cout<<orig<<‘ ‘<<c1<<‘\n’; | ^ answer.code: In function ‘void print(std::vector<long long int>)’: answer.code:17:69: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’} [-Wformat=] 17 | void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);} | ~^ | | | int | %lld answer.code: In function ‘int main()’: answer.code:80:13: error: ‘‘’ was not declared in this scope 80 | cout<<orig<<‘ ‘<<c1<<‘\n’; | ^ answer.code:100:42: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 100 | printf("%d\n",ans/2); | ~^ ~~~~~ | | | | int long long int | %lld answer.code:130:42: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 130 | printf("%d\n",ans); | ~^ ~~~ | | | | int long long int | %lld