QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#320794 | #8209. Curly Palindromes | ucup-team1134# | AC ✓ | 1ms | 3892kb | C++23 | 6.9kb | 2024-02-03 21:28:01 | 2024-02-03 21:28:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;
//幾何ライブラリ(整数)
class Point{
public:
ll x,y;
Point(ll x=0,ll y=0):x(x),y(y){}
Point operator + (Point p){return Point(x+p.x,y+p.y);}
Point operator - (Point p){return Point(x-p.x,y-p.y);}
Point operator * (ll a){return Point(a*x,a*y);}
double norm(){return x*x+y*y;}
bool operator < (const Point &p)const{
return x<p.x||(x==p.x&&y<p.y);
}
bool operator == (const Point &p)const{
return x==p.x&&y==p.y;
}
};
typedef Point Vector;
ll norm(Vector a){
return a.x*a.x+a.y*a.y;
}
ll dot(Vector a,Vector b){
return a.x*b.x+a.y*b.y;
}
ll cross(Vector a,Vector b){
return a.x*b.y-a.y*b.x;
}
struct Segment{
Point p1,p2;
};
bool isOrthogonal(Vector a,Vector b){
return dot(a,b)==0;
}
bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
return isOrthogonal(a1-a2,b1-b2);
}
bool isOrthogonal(Segment s1,Segment s2){
return dot(s1.p2-s1.p1,s2.p2-s2.p1)==0;
}
bool isParallel(Vector a,Vector b){
return cross(a,b)==0;
}
bool isParallel(Point a1,Point a2,Point b1,Point b2){
return isParallel(a1-a2,b1-b2);
}
bool isParallel(Segment s1,Segment s2){
return cross(s1.p2-s1.p1,s2.p2-s2.p1)==0;
}
//p0,p1,p2の順に見たときどうなるか?
static const int counter_clockwise=1;
static const int clockwise=-1;
static const int online_back=2;
static const int online_front=-2;
static const int on_segment=0;
int ccw(Point p0,Point p1,Point p2){
Vector a=p1-p0;
Vector b=p2-p0;
if(cross(a,b)>0) return counter_clockwise;
if(cross(a,b)<0) return clockwise;
if(dot(a,b)<0) return online_back;
if(a.norm()<b.norm()) return online_front;
return on_segment;
}
bool intersect(Point p1,Point p2,Point p3,Point p4){
return(ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
bool intersect(Segment s1,Segment s2){
return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}
bool overlap(Segment s1,Segment s2){
int a=ccw(s1.p1,s1.p2,s2.p1),b=ccw(s1.p1,s1.p2,s2.p2);
if(a&1||b&1) return 0;
if(a==2){
if(b==-2||(b==0&&!(s2.p2==s1.p1))) return 1;
else return 0;
}
if(a==-2){
if(b==2||(b==0&&!(s2.p2==s1.p2))) return 1;
else return 0;
}
if(a==0){
if(s1.p1==s2.p1){
if(b!=2) return 1;
else return 0;
}
else if(s1.p2==s2.p1){
if(b!=-2) return 1;
else return 0;
}
else return 1;
}
return 0;
}
//s1とs2の共通の線分(長さ0より大きい)があるかどうか
typedef Segment Line;
//ネットの適当を書いたのであってるか全く知りません→あってそう
class Circle{
public:
Point c;
ll r;
Circle(Point c=Point(),ll r=0.0):c(c),r(r){}
};
typedef vector<Point> Polygon;
/*
IN 2
ON 1
OUT 0
*/
int contains(Polygon g,Point p){
int n=int(g.size());
bool x=false;
for(int i=0;i<n;i++){
Point a=g[i]-p,b=g[(i+1)%n]-p;
if(a.y>b.y) swap(a,b);
if(a.y<=0&&0<b.y&&cross(a,b)<0) x=!x;
if(abs(cross(a,b))<=0&&dot(a,b)<=0) return 1;
}
return (x?2:0);
}
//ayasii
Polygon andrewScan(Polygon s,bool ok){
Polygon u,l;
sort(all(s));
if(int(s.size())<3) return s;
int n=int(s.size());
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[n-1]);
l.push_back(s[n-2]);
if(ok){
for(int i=2;i<n;i++){
for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])==counter_clockwise;j--){
u.pop_back();
}
u.push_back(s[i]);
}
for(int i=int(s.size())-3;i>=0;i--){
for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])==counter_clockwise;j--){
l.pop_back();
}
l.push_back(s[i]);
}
}
if(!ok){
for(int i=2;i<n;i++){
for(int j=int(u.size());j>=2&&ccw(u[j-2],u[j-1],s[i])!=clockwise;j--){
u.pop_back();
}
u.push_back(s[i]);
}
for(int i=int(s.size())-3;i>=0;i--){
for(int j=int(l.size());j>=2&&ccw(l[j-2],l[j-1],s[i])!=clockwise;j--){
l.pop_back();
}
l.push_back(s[i]);
}
}
reverse(all(l));
for(int i=int(u.size())-2;i>=1;i--) l.push_back(u[i]);
return l;
}//ok==1なら辺の上も含める
ll area(Polygon P){
ll sum=0;
for(int i=0;i<si(P);i++){
sum+=cross(P[i],P[(i+1)%si(P)]);
}
return abs(sum);
}
// 倍
ll gcd(ll a,ll b){
if(b==0) return a;
return gcd(b,a%b);
}
pair<Point,Vector> perpendicular_bisector(Point a,Point b){
Point c;
c.x=(a.x+b.x)/2;
c.y=(a.y+b.y)/2;
Vector v=b-c;
swap(v.x,v.y);
v.x*=-1;
Point p=c;
if(v.x==0){
v.y=1;
p.y=0;
}
else if(v.y==0){
v.x=1;
p.x=0;
}
else{
if(v.x<0){
v.x*=-1;
v.y*=-1;
}
ll g=gcd(abs(ll(v.x)),abs(ll(v.y)));
v.x/=g;
v.y/=g;
if(p.x>=0){
ll d=p.x/v.x;
p=p-v*d;
}else{
ll d=abs(p.x)/v.x;
p=p+v*d;
if(p.x<0){
p=p+v;
}
}
}
return mp(p,v);
}
//2倍するなりして整数にしておくこと
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int N;cin>>N;
vector<Point> P(N);
vector<char> S(N);
for(int i=0;i<N;i++){
cin>>P[i].x>>P[i].y>>S[i];
}
for(int a=0;a<N;a++){
for(int b=a+1;b<N;b++){
for(int c=b+1;c<N;c++){
if(S[a]==S[b]||S[b]==S[c]||S[c]==S[a]){
ll x=ccw(P[a],P[b],P[c]);
if(x==1||x==-1){
cout<<"Infinity\n";
return 0;
}
}
}
}
}
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
if(S[i]==S[j]){
cout<<2<<"\n";
return 0;
}
}
}
cout<<1<<"\n";
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3888kb
input:
4 0 0 o 1 1 c 2 2 p 3 3 c
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
3 2 3 e 3 2 e 8 9 e
output:
Infinity
result:
ok single line: 'Infinity'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
3 0 0 p 1 1 c 2 2 o
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
3 1000000000 1000000000 a 0 1000000000 b 1000000000 0 a
output:
Infinity
result:
ok single line: 'Infinity'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
5 10 0 a 20 0 b 30 0 c 41 0 d 42 0 e
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
6 999999999 1000000000 b 0 0 a 1 1 a 2 2 c 3 3 d 4 4 e
output:
Infinity
result:
ok single line: 'Infinity'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
1 52524 6287 o
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
100 620277501 352211578 a 588745387 204868067 a 279087773 862840409 a 368942847 32429835 a 986161321 811576403 a 108066135 22119129 a 854047430 512772131 a 196877261 824967276 a 467809712 903492464 a 549499819 662329823 a 358024530 364859507 a 323528347 87306983 a 346602511 829302399 a 216164493 243...
output:
Infinity
result:
ok single line: 'Infinity'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
100 964906060 545884156 b 525844995 678718384 a 767874103 529057847 b 335899480 961060244 b 458611128 578152716 b 449062933 779433747 a 672526007 895103745 b 111902255 436806217 a 873636242 773662394 a 250185459 522336127 a 975489206 77297854 b 54583166 952092302 a 863604349 909716224 a 70170689 533...
output:
Infinity
result:
ok single line: 'Infinity'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
100 197441358 388148939 b 374082779 922588431 b 545855650 531926491 b 953289473 249626190 a 997668672 445922624 b 941714598 963970889 a 252303702 946260915 c 705178416 744961339 a 889814639 633539049 b 526449032 53699804 b 937365752 742338401 b 294384909 349114633 b 245948038 979810742 c 46734037 30...
output:
Infinity
result:
ok single line: 'Infinity'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
100 388507460 599009943 b 222320564 871491185 b 323837196 829762427 d 202083245 906788357 c 200289725 313692532 c 65770043 517104251 d 905710326 292385376 b 3487284 126745388 b 495927620 829852193 b 97679895 880030775 b 677903935 407378948 d 534186652 672508037 b 964728216 976276332 b 391893605 5597...
output:
Infinity
result:
ok single line: 'Infinity'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
100 916010051 146307434 c 480623765 410328522 d 28189815 127598363 c 745844310 195354303 c 739347268 591527857 d 484792781 775270322 b 190520730 638509838 d 6828862 434900510 b 512106017 321132628 e 668910759 411394452 b 639780481 72419495 a 773988394 364497659 c 347071905 341338141 d 368456952 5180...
output:
Infinity
result:
ok single line: 'Infinity'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
100 86229674 966475154 g 188905509 869037044 j 206431319 885238671 g 384203494 608011484 b 94907195 845681979 j 93491181 751753218 f 658592436 874867662 j 390873056 182636414 b 313350178 5306341 j 964520327 884419573 c 616180319 281427186 e 506244230 796896398 b 427455351 844237339 f 78090262 517379...
output:
Infinity
result:
ok single line: 'Infinity'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
100 215977786 124594064 t 330805101 191632694 a 89113834 355297431 h 763543468 766857893 i 129574380 326152621 t 980011509 580824171 l 593104211 610936942 p 433305160 169599834 n 169733556 636573400 d 529043807 454466372 h 898931244 35490902 l 277816100 810116698 c 35985918 405195648 i 188992394 893...
output:
Infinity
result:
ok single line: 'Infinity'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
100 708120351 620407913 n 535329934 654852971 t 609745260 478749536 q 362094763 276915210 s 280981242 647870195 n 936373080 162431905 h 260497437 466345348 o 181689176 124319222 n 488142303 321448453 b 39367382 527550314 k 301142721 730766894 n 126691970 634927413 k 412986447 268439483 x 227790067 4...
output:
Infinity
result:
ok single line: 'Infinity'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
26 526735598 478961006 a 531191531 475454507 b 378204498 595844306 c 442072871 545584487 d 525250287 480129839 e 498514689 501168833 f 568324306 446233682 g 470293780 523376660 h 554956507 456753179 i 455440670 535064990 j 397513541 580649477 k 612883636 411168692 l 513367799 489480503 m 465837847 5...
output:
1
result:
ok single line: '1'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
100 548848602 549471818 a 320148329 317853761 b 508881564 508994876 c 704275972 706882148 d 371217322 369574298 e 597697204 598943636 f 624341896 625928264 g 380098886 378569174 h 313487156 311107604 i 553289384 553969256 j 466694135 466269215 k 406743578 405553802 l 488898045 488756405 m 653206979 ...
output:
2
result:
ok single line: '2'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
100 509098504 507901696 w 513647756 511852544 t 638752186 620500864 f 565964154 557287296 e 438585098 446663552 s 283910530 312334720 l 702441714 675812736 g 295283660 322211840 h 561414902 553336448 b 434035846 442712704 g 688793958 663960192 n 447683602 454565248 o 320304546 343941504 c 540943268 ...
output:
2
result:
ok single line: '2'
Extra Test:
score: 0
Extra Test Passed