省赛训练小结1
C - Bowling
There are some number of bowling pins on a plane. Four people are observing the pins from different angles. Is it possible that one of the observers sees much more pins than the others?
Let's model the pins as a set of points on an xyxy-plane. The image below shows the positions of the four observers. Formally,
- For observer A, two pins overlap if their yy-coordinates are the same.
- For observer B, two pins overlap if their values of (xx-coordinate minus yy-coordinate) are the same.
- For observer C, two pins overlap if their xx-coordinates are the same.
- For observer D, two pins overlap if their values of (xx-coordinate plus yy-coordinate) are the same.
Let a,b,c,da,b,c,d be the number of pins the observers A, B, C, D see, respectively.
Construct any arrangement of bowling pins that satisfies the following constraints:
- d≥10⋅max{a,b,c}d≥10⋅max{a,b,c}
- The number of pins is between 11 and 105105, inclusive.
- The coordinates are integers between 00 and 109109, inclusive.
- No two pins are placed at exactly the same place.
Input
There is no input.
Output
Print the answer in the following format, where NN is the number of pins and (xi,yi)(xi,yi) are the coordinates of the ii-th pin:
NN x1x1 y1y1 :: xNxN yNyN
It must satisfy the conditions in the statement.
Sample Input 1
Sample Output 1
9 1 1 1 5 2 7 4 4 5 3 6 8 7 5 8 2 8 7
This sample output is provided for the sake of showing the output format and is not correct.
It matches the picture in the statement.
Here, d=8d=8 and a=b=c=7a=b=c=7. Nice try, but not enough to get AC.
题意:就是从A,B,C,D四个方向去看球,但是需要看到d球的个数是abc中最大球个数的10倍
主要思路:这道题应该是使用找规律的方法而不是使用单单的枚举,lmy大佬的方法是先找出那几个,然后只要保证1000i+k,10000j+k满足即可(有一个1k倍数的差距)
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef struct { int x,y; }node; node a[1100]; node t1; node t2; node t3; int cmp(node &a,node &b) { if(a.x!=b.x) return a.x<b.x; return a.y<b.y; } int main() { int gs=0; t1.x=21,t1.y=0; t2.x=0,t2.y=1000; t3.x=1,t3.y=1; for(int i=1;i<=10;i++) { for(int j=1;j<=10;j++) { for(int k=1;k<=10;k++) { gs++; a[gs].x=t1.x*i+t3.x*k; a[gs].y=t2.y*j+t3.y*k; } } } // cout<<gs<<"????"<<endl; sort(a+1,a+1+gs,cmp); cout<<"1000"<<endl; for(int i=1;i<=gs;i++) cout<<a[i].x<<" "<<a[i].y<<endl; return 0; }
I - Vera and Dogs
Vera owns N doghouses numbered from 1 to N and M = X·N dogs numbered from 1 to M. Each doghouse should be the primary home of X dogs Pi, 1, ..., Pi, X and the secondary home of X dogs Si, 1, ..., Si, X. Each dog should have one primary home and one secondary home different from its primary home. Every night, at most one doghouse might be unavailable due to cleaning. Each dog will sleep in its primary home if it is available, otherwise it will sleep in its secondary home. Each doghouse should contain at most X + 1 sleeping dogs on any night.
Help Vera find a valid assignment of doghouses to dogs, or determine that it is impossible.
Input
Line 1 contains integers N and X (1 ≤ N, X ≤ 2017, X·N ≤ 50000).
Output
If it is impossible to find a valid assignment, print one line with - 1.
Otherwise print N lines. The i-th line should contain 2X integers Pi, 1, ..., Pi, X, Si, 1, ..., Si, X. If there are multiple possible assignments, print any of them.
Examples
3 2
5 1 6 4
3 6 5 2
4 2 1 3
2 2
-1
Note
For the first example:
Doghouse 1 is the primary home of dogs 5 and 1 and secondary home of dogs 6 and 4. If doghouse 1 is unavailable, then dog 1 will sleep in doghouse 3 and dog 5 will sleep in doghouse 2.
Doghouse 2 is the primary home of dogs 3 and 6 and secondary home of dogs 5 and 2. If doghouse 2 is unavailable, then dog 3 will sleep in doghouse 3 and dog 6 will sleep in doghouse 1.
Doghouse 3 is the primary home of dogs 4 and 2 and secondary home of dogs 1 and 3. If doghouse 3 is unavailable, then dog 4 will sleep in doghouse 1 and dog 2 will sleep in doghouse 2.
So it can be seen that no doghouse will ever contain more than 3 dogs.
狗笼问题 在做题目的时候一直在纠结到底怎么样才可以输出和题目一样的狗笼(因为就算是题目中给出的3 2的样例也有很多不同的输出方式 结果可以有存在差异 既然这样的话那其实就简单多了)
主要是对其矩阵进行分块化处理 一边的矩阵按照顺序处理数字,另外一边则是按照一个排列的顺序,则第一排的x只狗应该取x+1--x+x(如果有大于n的则是取余)
这样一理解题目就变得轻松加愉快了
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <vector> using namespace std; vector<int> q[2020]; int main() { int n,x; cin>>n>>x; int num=0; if(x>=n) cout<<"-1"<<endl; else { for(int i=1;i<=n;i++) { for(int j=1;j<=x;j++) { num++; q[(i+j)%n].push_back(num); } }//第几行 int num=0; q[n]=q[0]; for(int i=1;i<=n;i++) { for(int j=1;j<=x;j++) { num++; printf("%d ",num); } // cout<<q[i].size()<<endl; for(int j=0;j<=q[i].size()-1;j++) { cout<<q[i][j]; if(j!=q[i].size()-1) cout<<" "; else cout<<endl; } // cout<<"??"<<endl; } // cout<<q[3].size()-1<<"??"<<endl; } return 0; }
其实比赛的时候就是太太太紧张了,然后什么题目都会做不出来很愚钝

浙公网安备 33010602011771号