usaco 洛谷 P2694 接金幣 題解

題目描述

在二維座標系裏,有N個金幣,編號0至N-1。初始時,第i個金幣的座標是(Xi,Yi)。全部的金幣每秒向下垂直降低一個單位高度,例若有個金幣當前座標是(xf, yf),那麼t秒後金幣所在的位置就是(xf, yf-t)。初始時,FJ在(0,0)座標處,FJ每秒只能向左移動一個單位距離或者向右移動一個單位距離,固然FJ也能夠不移動。若是在某個時刻某個金幣和FJ所在的位置重合,那麼FJ就能接住這個金幣。FJ可否把全部的金幣都接住?若是行輸出Abletocatch,不然輸出Notabletocatch。ios

輸入輸出格式

輸入格式:ide

 

多組測試數據。測試

第一行,一個整數G,表示有G組測試數據。1 <= G <= 5。spa

每組測試數據格式以下:code

第一行,一個整數N。 1 <= N <= 50。blog

接下來有N行,第i行兩個整數表示Xi、Yi。ip

-1000<=Xi<=1000。0<=Yi<=1000。

 

輸出格式:ci

 

共G行,每行輸出Abletocatch或Notabletocatch。get

 

輸入輸出樣例

輸入樣例#1:
5
3
-1 1
1 3
0 4
1
-3 2
3
-1 1
1 2
0 4
3
0 9
-1 1
1 3
8
70 141
-108 299
52 402
-70 280
84 28
-29 363
66 427
-33 232
輸出樣例#1:
Abletocatch
Notabletocatch
Notabletocatch
Abletocatch
Notabletocatch
————————————————————————————————————我是分割線——————————————————————————————————————————
純模擬。水題目。
 1 /*
 2     Problem:
 3     OJ:
 4     User:    S.B.S.
 5     Time:
 6     Memory:
 7     Length:
 8 */
 9 #include<iostream>
10 #include<cstdio>
11 #include<cstring>
12 #include<cmath>
13 #include<algorithm>
14 #include<queue>
15 #include<cstdlib>
16 #include<iomanip>
17 #include<cassert>
18 #include<climits>
19 #include<functional>
20 #include<bitset>
21 #include<vector>
22 #include<list>
23 #define F(i,j,k) for(int i=j;i<=k;++i)
24 #define M(a,b) memset(a,b,sizeof(a))
25 #define FF(i,j,k) for(int i=j;i>=k;i--)
26 #define maxn 10001
27 #define inf 0x3f3f3f3f
28 #define maxm 4001
29 #define mod 998244353
30 //#define LOCAL
31 using namespace std;
32 int read(){
33     int x=0,f=1;char ch=getchar();
34     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
35     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
36     return x*f;
37 }
38 int n,m;
39 int data[1001];
40 int main(int argc,const char *argv)
41 {
42     std::ios::sync_with_stdio(false);//cout<<setiosflags(ios::fixed)<<setprecision(1)<<y;
43     #ifdef LOCAL
44     freopen("data.in","r",stdin);
45     freopen("data.out","w",stdout);
46     #endif
47     int g;cin>>g;
48     while(g--){
49         cin>>n;bool flag=false;
50         F(i,1,1000) data[i]=-inf;
51         F(i,1,n){
52             int x,y;
53             cin>>x>>y;
54             if(data[y]!=-inf&&x!=data[y]){flag=true;}
55             if(data[y]!=-inf) continue;
56             data[y]=x;
57         }
58         if(flag==true){cout<<"Notabletocatch"<<endl;continue;}
59         int pos=0,pre=0;flag=false;data[0]=0;
60 //        F(i,1,n) cout<<data[i]<<" "<<endl;
61         F(i,1,1000){
62             if(data[i]==-inf) continue;
63             int time=abs(i-pre);
64 //            cout<<i<<" "<<pre<<" "<<data[i]<<" "<<data[pre]<<endl;
65             if(abs(data[i]-data[pre])>time){flag=true;break;}
66             pre=i;
67         }
68         if(flag==true) cout<<"Notabletocatch"<<endl;
69         else cout<<"Abletocatch"<<endl;
70     }
71     return 0;
72 }
p2964
相關文章
相關標籤/搜索