求解

P2694 接金币

@[zhangchenxi](/user/875250) if语句中的“break”只能跳出for这一层循环,并不能跳出最外层的while循环,也就是说,存在一种情况,输出Notabletocatch后还会输出Abletocatch
by CyberRiot @ 2023-06-27 23:18:41


@[zhangchenxi](/user/875250) ```cpp #include <bits/stdc++.h> using namespace std; struct xy{ int x,y; }; int g,n; xy a[60]; bool cmp(xy a,xy b){ return a.y<b.y; } int main(){ cin>>g; while(g--){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y; sort(a+1,a+1+n,cmp); a[0].x=0,a[0].y=0; bool flag=0; for(int i=1;i<=n;i++){ if(abs(a[i].x-a[i-1].x)>abs(a[i].y-a[i-1].y)) flag=1; } if(flag==0) cout<<"Abletocatch"<<endl; else cout<<"Notabletocatch"<<endl; } return 0; } ``` 这样就能过了 [评测记录](https://www.luogu.com.cn/record/113431527)
by CyberRiot @ 2023-06-27 23:21:17


谢谢
by zhangchenx @ 2023-09-16 18:45:39


|