Solved Pro.ID Title Ratio(Accepted / Submitted)
1001 String 11.88%(125/1052)
1002 Dragon slayer 19.56%(473/2418)
1003 Backpack 14.23%(270/1897)
1004 Ball 15.29%(52/340)
1005 Grammar 12.21%(21/172)
1006 Travel plan 24.18%(22/91)
1007 Treasure 12.93%(38/294)
1008 Path 14.01%(50/357)
1009 Laser 22.58%(280/1240)
1010 Walk 16.67%(4/24)
1011 Random 33.83%(861/2545)
1012 Alice and Bob 11.90%(604/5077)
Problem Description
N numbers, randomly generated between [0,1]
Make M operation, 12 probability to delete the maximum value, 12 probability to delete the minimum value
Calculate the sum of expected value module 109+7
Input
Each test contains multiple test cases. The first line contains the number of test cases T(1≤T≤10000). Description of the test cases follows.
The first line of each test case contains two integers n,m
1≤m≤n≤109
Output
For each test case, print one integer — the answer to the problem.
Sample Input
2
2 2
3 1
Sample Output
0
1
Source
2022“杭电杯”中国大学生算法设计超级联赛(1)
题意:
思路:
#include
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
void exgcd(LL a, LL b, LL &d, LL &x, LL & y, LL MOD) { if (b==0) { d = a; x = 1; y = 0; } else { exgcd(b, a % b, d, y, x, MOD); y -= x * (a / b); } }
LL inv(LL a, LL MOD) { LL d=0, x=0, y=0; exgcd(a, MOD, d, x, y, MOD); return d == 1 ? (x + MOD) % MOD : -1;
int main(){
int T; cin>>T;
while(T--){
LL n, m; cin>>n>>m;
cout<<(n-m+mod)*inv(2,mod)%mod<<"\n";
}
return 0;
}
Problem Description
Alice and Bob like playing games.
There are m numbers written on the blackboard, all of which are integers between 0 and n.
The rules of the game are as follows:
If there are still numbers on the blackboard, and there are no numbers with value 0 on the blackboard, Alice can divide the remaining numbers on the blackboard into two sets.
Bob chooses one of the sets and erases all numbers in that set. Then subtract all remaining numbers by one.
At any time, if there is a number with a value of 0 on the blackboard, Alice wins; otherwise, if all the numbers on the blackboard are erased, Bob wins.
Please determine who will win the game if both Alice and Bob play the game optimally.
Input
The first line contains an integer T(T≤2000) —the number of test cases.
The first line of each test case contains a single integers n(1≤∑n≤106) .
The second line of each test case contains n+1 integers a0,a1,a2…an(0≤ai≤106,∑ai=m) — there are ai numbers with value i on the blackboard .
Output
For each test case, print “Alice” if Alice will win the game, otherwise print “Bob”.
Sample Input
2
1
0 1
1
0 2
Sample Output
Bob
Alice
题意:
思路:
//1012
#include
using namespace std;
const int maxn = 1e6+10;
int a[maxn];
int main(){
int T; cin>>T;
while(T--){
int n; cin>>n;
for(int i = 1; i <= n+1; i++)cin>>a[i];
for(int i = n+1; i >= 2; i--)
a[i-1]+=a[i]/2;
if(a[1]>=1)cout<<"Alice\n";
else cout<<"Bob\n";
}
return 0;
}
Dragon slayer
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1021 Accepted Submission(s): 291
Problem Description
Long, long ago, the dragon captured the princess. In order to save the princess, the hero entered the dragon’s lair.
The dragon’s lair is a rectangle area of length n and width m. The lower left corner is (0,0) and the upper right corner is (n,m).
The position of the hero is (xs+0.5,ys+0.5).
The position of the dragon is (xt+0.5,yt+0.5).
There are some horizontal or vertical walls in the area. The hero can move in any direction within the area, but cannot pass through walls, including the ends of walls.
The hero wants to go where the dragon is, but may be blocked by walls.
Fortunately, heroes have access to special abilities, and each use of a special ability can make a wall disappear forever.
Since using special abilities requires a lot of physical strength, the hero wants to know how many times special abilities need to be used at least on the premise of being able to reach the position of the evil dragon?
Input
The first line contains an integer T(T≤10) —the number of test cases.
The first line of each test case contains 3 integers n,m,K(1≤n,m,K≤15) —length and width of rectangular area, number of walls
The second line of each test case contains 4 integers xs,ys,xt,yt(0≤xs,xt The next K lines , each line contains 4 integers x1,y1,x2,y2(0≤x1,x2≤n,0≤y1,y2≤m) — indicates the location of the two endpoints of the wall, ensuring that x1=x2 or y1=y2. Output Sample Input Sample Output Source 题意: 思路: Laser Problem Description You now have a laser weapon, which you can place on any grid (x,y)(x, y are real numbers) , and the weapon fires a powerful laser that for any real number k, enemies at coordinates (x+k,y),(x,y+k),(x+k,y+k),(x+k,y−k) will be destroyed. You are now wondering if it is possible to destroy all enemies with only one laser weapon. Input For each case, first line input a positive integer n to represent the position of the enemy. Next n line, the i-th line inputs two integers xi,yi(−108≤xi,yi≤108) represents the position of the i-th enemy. The data guarantees that the sum of n for each test case does not exceed 500,000 Output Sample Input Sample Output Source 题意: 思路: Backpack Problem Description Alice has n items, each of which has a volume vi and a value wi. Can a number of items be selected from n items such that the backpack is exactly full (ie the sum of the volumes equals the backpack capacity)? If so, what is the maximum XOR sum of the values of the items in the backpack when the backpack is full? Input The first line of each test case contains 2 integers n,m(1≤n,m<210) —the number of items, the capacity of the backpack. The next n lines , each line contains 2 integers vi,wi(1≤vi,wi<210) — the volume and value of the item. Output Sample Input Sample Output Source 题意: 思路:
For each test case, a line of output contains an integer representing at least the number of times the special ability was required.
2
3 2 2
0 0 2 1
0 1 3 1
1 0 1 2
3 2 2
0 0 2 1
2 1 2 2
1 0 1 1
2
0
2022“杭电杯”中国大学生算法设计超级联赛(1)//1002
#includeI. Laser
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 879 Accepted Submission(s): 219
There are n enemies on a two-dimensional plane, and the position of the i-th enemy is (xi,yi)
The first line of input is a positive integer T(T≤105) representing the number of data cases.
For each cases, If all enemies can be destroyed with one laser weapon, output “YES“, otherwise output “NO“(not include quotation marks).
2
6
1 1
1 3
2 2
3 1
3 3
3 4
7
1 1
1 3
2 2
3 1
3 3
1 4
3 4
YES
NO
2022“杭电杯”中国大学生算法设计超级联赛(1)//1009
#includeC. Backpack
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1642 Accepted Submission(s): 524
Alice has a backpack of capacity m that she now wants to fill with some items!
The first line contains an integer T(T≤10) —the number of test cases.
For each test case, output a single line, if the backpack cannot be filled, just output a line of “-1”, otherwise output the largest XOR sum.
1
5 4
2 4
1 6
2 2
2 12
1 14
14
2022“杭电杯”中国大学生算法设计超级联赛(1)
如果改为前i个物品,体积为j时能获得的最大异或和,发现无法进行转移,因为前面的值会影响后面的状态,不具有无后向性。//1003
#include