AIM Tech Round 5(A,B,C)

比赛链接:AIM Tech Round 5

Find Square

找左上和右下为B的,拿(x1+x2)/2和(y1+y2)/2。

 1 #include <set>
 2 #include <map>
 3 #include <queue>
 4 #include <deque>
 5 #include <stack>
 6 #include <cmath>
 7 #include <cstdio>
 8 #include <vector>
 9 #include <string>
10 #include <cstring>
11 #include <fstream>
12 #include <iostream>
13 #include <algorithm>
14 using namespace std;
15 
16 #define eps 1e-8
17 #define PI acos(-1.0)
18 #define INF 0x3f3f3f3f
19 #define FAST_IO ios::sync_with_stdio(false)
20 
21 typedef long long LL;
22 char s[300][300];
23 
24 int main(){
25     FAST_IO;
26     int n,m;
27     cin>>n>>m;
28     int s1=-1,s2=-1;
29     int e1=-1,e2=-1;
30     for(int i=1;i<=n;i++){
31         for(int j=1;j<=m;j++){
32             cin>>s[i][j];
33             if(s[i][j]=='B'){
34                 if(s1==-1) s1=i,e1=j;
35                 s2=i;e2=j;
36             }
37         }
38     }
39     //cout<<s1<<" "<<e1<<" "<<s2<<" "<<e2<<endl;
40     cout<<(s1+s2)/2<<" "<<(e1+e2)/2<<endl;
41     return 0;
42 }
View Code

Unnatural Conditions

凑一凑,2000个4 和 1999个5+个6。

 1 #include <set>
 2 #include <map>
 3 #include <queue>
 4 #include <deque>
 5 #include <stack>
 6 #include <cmath>
 7 #include <cstdio>
 8 #include <vector>
 9 #include <string>
10 #include <cstring>
11 #include <fstream>
12 #include <iostream>
13 #include <algorithm>
14 using namespace std;
15 
16 #define eps 1e-8
17 #define PI acos(-1.0)
18 #define INF 0x3f3f3f3f
19 #define FAST_IO ios::sync_with_stdio(false)
20 
21 typedef long long LL;
22 
23 int main(){
24     FAST_IO;
25     int n,m;
26     cin>>n>>m;
27     int a1=m/2;
28     int a2=m-m/2;
29     for(int i=1;i<=2000;i++) cout<<4;
30     cout<<endl;
31     for(int i=1;i<2000;i++) cout<<5;
32     cout<<6<<endl;
33     return 0;
34 }
View Code

Rectangles

和上场的C一样,左下要尽可能右上,右上要尽可能左下。左下的弄个最右、次右和最上、次上;右上的弄个最左、次左和最下、次下。记录各个的数量,每次遍历删除当前矩阵,从剩下的挑交集。

 1 #include <set>
 2 #include <map>
 3 #include <queue>
 4 #include <deque>
 5 #include <stack>
 6 #include <cmath>
 7 #include <cstdio>
 8 #include <vector>
 9 #include <string>
10 #include <cstring>
11 #include <fstream>
12 #include <iostream>
13 #include <algorithm>
14 #include <unordered_map>
15 using namespace std;
16 
17 #define eps 1e-8
18 #define PI acos(-1.0)
19 #define INF 0x3f3f3f3f
20 #define FAST_IO ios::sync_with_stdio(false)
21 
22 const int N=2e5+10;
23 typedef long long LL;
24 int x1[N],y1[N],x2[N],y2[N];
25 unordered_map <int,int> m1;
26 unordered_map <int,int> m2;
27 unordered_map <int,int> m3;
28 unordered_map <int,int> m4;
29 
30 int main(){
31     int n;
32     scanf("%d",&n);
33     int a1=-INF,a2=-INF,b1=-INF,b2=-INF,c1=INF,c2=INF,d1=INF,d2=INF;
34     for(int i=1;i<=n;i++){
35         scanf("%d%d%d%d",&x1[i],&y1[i],&x2[i],&y2[i]);
36         m1[x1[i]]++;m2[y1[i]]++;m3[x2[i]]++;m4[y2[i]]++;
37         if(x1[i]>a1){
38             a2=a1;
39             a1=x1[i];
40         }
41         else if(x1[i]>a2){
42             a2=x1[i];
43         }
44         if(y1[i]>b1){
45             b2=b1;
46             b1=y1[i];
47         }
48         else if(y1[i]>b2){
49             b2=y1[i];
50         }
51         if(x2[i]<c1){
52             c2=c1;
53             c1=x2[i];
54         }
55         else if(x2[i]<c2){
56             c2=x2[i];
57         }
58         if(y2[i]<d1){
59             d2=d1;
60             d1=y2[i];
61         }
62         else if(y2[i]<d2){
63             d2=y2[i];
64         }
65     }
66     int l1=x1[1],r1=y1[1],l2=x2[1],r2=y2[1];
67     for(int i=1;i<=n;i++){
68         m1[x1[i]]--;m2[y1[i]]--;m3[x2[i]]--;m4[y2[i]]--;
69         if(m1[a1]==0) l1=a2;
70         else l1=a1;
71         if(m2[b1]==0) r1=b2;
72         else r1=b1;
73         if(m3[c1]==0) l2=c2;
74         else l2=c1;
75         if(m4[d1]==0) r2=d2;
76         else r2=d1;
77         if(l1<=l2&&r1<=r2){
78             cout<<l2<<" "<<r2<<endl;
79             return 0;
80         }
81         m1[x1[i]]++;m2[y1[i]]++;m3[x2[i]]++;m4[y2[i]]++;
82     }
83 
84     return 0;
85 }
View Code

猜你喜欢

转载自www.cnblogs.com/ehanla/p/9545759.html
今日推荐