码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • SDUT 2022 summer team contest 6th(for 21)


    A - Secrete Master Plan

    Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a pocket. The plan instructs how to deploy soldiers on the four corners of the city wall. Unfortunately, when Fei opened the pocket he found there are only four numbers written in dots on a piece of sheet. The numbers form 2×22×2 matrix, but Fei didn't know the correct direction to hold the sheet. What a pity!

    Given two secrete master plans. The first one is the master's original plan. The second one is the plan opened by Fei. As KongMing had many pockets to hand out, he might give Fei the wrong pocket. Determine if Fei receives the right pocket.

    Input

    The first line of the input gives the number of test cases, T(1≤T≤10^4)T(1≤T≤104). TT test cases follow. Each test case contains 4 lines. Each line contains two integers a_{i0}ai0​ and a_{i1}ai1​ (1≤a_{i0},a_{i1}≤1001≤ai0​,ai1​≤100). The first two lines stands for the original plan, the 3_{rd}3rd​ and 4_{th}4th​ line stands for the plan Fei opened.

    Output

    For each test case, output one line containing "Case #x: y", where x is the test case number
    (starting from 1) and yy is either "POSSIBLE" or "IMPOSSIBLE" (quotes for clarity).

    Sample

    InputcopyOutputcopy
     
    4 1 2 3 4 1 2 3 4 1 2 3 4 3 1 4 2 1 2 3 4 3 2 4 1 1 2 3 4 4 3 2 1
     
    Case #1: POSSIBLE Case #2: POSSIBLE Case #3: IMPOSSIBLE Case #4: POSSIBLE

    1. /*Where there is light, in my heart.*/
    2. /*SUMMER_TRAINING*/
    3. #include
    4. #include
    5. #include
    6. #include
    7. #include
    8. using namespace std;
    9. //
    10. #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    11. #define INF 0x3f3f3f
    12. #define ll long long
    13. #define INF 0x3f3f3f3f
    14. #define mem(a,b) memset(a,b,sizeof(a))
    15. #define unmap(a,b) unordered_map
    16. #define unset(a) unordered_set
    17. #define F first
    18. #define S second
    19. #define pb push_back
    20. #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
    21. #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
    22. #define mode 1e4+7
    23. #define pi acos(-1)
    24. #define U_queue priority_queue,greater >
    25. typedef double db;
    26. typedef pair<int,int> PII;
    27. typedef pair PLL;
    28. typedef vector<int> vi;
    29. const int N = 5010;
    30. //====================================================//
    31. int num;
    32. void solve(){
    33. num++;
    34. int a,b,c,d;
    35. cin>>a>>b>>c>>d;
    36. int e,f,g,h;
    37. cin>>e>>f>>g>>h;
    38. if(e==a&&f==b&&g==c&&h==d)
    39. printf("Case #%d: POSSIBLE\n",num);
    40. else if(e==c&&f==a&&g==d&&h==b)
    41. printf("Case #%d: POSSIBLE\n",num);
    42. else if(e==d&&f==c&&g==b&&h==a)
    43. printf("Case #%d: POSSIBLE\n",num);
    44. else if(e==b&&f==d&&g==a&&h==c)
    45. printf("Case #%d: POSSIBLE\n",num);
    46. else
    47. printf("Case #%d: IMPOSSIBLE\n",num);
    48. }
    49. signed main(){
    50. int t;
    51. scanf("%d",&t);
    52. while(t--){
    53. //for(int i=2;i<=t;i++){
    54. solve();
    55. }
    56. }
    57. //made by melody 20220806

    G - Ancient Go

    Yu Zhou likes to play Go with Su Lu. From the historical research, we found that there are much difference on the rules between ancient go and modern go.

    Here is the rules for ancient go they were playing:

    \cdot⋅The game is played on a 8×88×8 cell board, the chess can be put on the intersection of the board lines, so there are 9×99×9 different positions to put the chess.
    \cdot⋅Yu Zhou always takes the black and Su Lu the white. They put the chess onto the game board alternately.
    \cdot⋅The chess of the same color makes connected components(connected by the board lines), for each of the components, if it's not connected with any of the empty cells, this component dies and will be removed from the game board.
    \cdot⋅When one of the player makes his move, check the opponent's components first. After removing the dead opponent's components, check with the player's components and remove the dead components.
    One day, Yu Zhou was playing ancient go with Su Lu at home. It's Yu Zhou's move now. But they had to go for an emergency military action. Little Qiao looked at the game board and would like to know whether Yu Zhou has a move to kill at least one of Su Lu's chess.

    Input

    The first line of the input gives the number of test cases, T(1≤T≤100)T(1≤T≤100). TT test cases follow. Test cases are separated by an empty line. Each test case consist of 9 lines represent the game board. Each line consists of 9 characters. Each character represents a cell on the game board. '.'′.′ represents an empty cell. 'x'′x′ represents a cell with black chess which owned by Yu Zhou. 'o'′o′ represents a cell with white chess which owned by Su Lu.

    Output

    For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is Can kill in one move!!! if Yu Zhou has a move to kill at least one of Su Lu's components. Can not kill in one move!!! otherwise.

    Sample

    InputcopyOutputcopy
     
    2 .......xo ......... ......... ..x...... .xox....x .o.o...xo ..o...... .....xxxo ....xooo. ......ox. .......o. ...o..... ..o.o.... ...o..... ......... .......o. ...x..... ........o
     
    Case #1: Can kill in one move!!! Case #2: Can not kill in one move!!!

    Hint


    In the first test case, Yu Zhou has 4 different ways to kill Su Lu's component.

    In the second test case, there is no way to kill Su Lu's component.

    固定的88地图 直接暴力

    1. /*Where there is light, in my heart.*/
    2. /*SUMMER_TRAINING*/
    3. #include
    4. #include
    5. #include
    6. #include
    7. #include
    8. using namespace std;
    9. //
    10. #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    11. #define ll long long
    12. #define INF 0x3f3f3f3f
    13. #define mem(a,b) memset(a,b,sizeof(a))
    14. #define unmap(a,b) unordered_map
    15. #define unset(a) unordered_set
    16. #define F first
    17. #define S second
    18. #define pb push_back
    19. #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
    20. #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
    21. #define mode 1e4+7
    22. #define pi acos(-1)
    23. #define U_queue priority_queue,greater >
    24. typedef double db;
    25. typedef pair<int,int> PII;
    26. typedef pair PLL;
    27. typedef vector<int> vi;
    28. const int N = 1e3+5;
    29. const int mod=1e9+7;
    30. //====================================================//
    31. int num;
    32. char a[10][10];
    33. bool st[10][10];
    34. int fx[]={0,0,1,-1};
    35. int fy[]={1,-1,0,0};
    36. bool check(int x,int y){
    37. if(x>0&&x<=9&&y>0&&y<=9&&st[x][y]==false) return true;
    38. return false;
    39. }
    40. int dfs(int x,int y){
    41. st[x][y]=1;
    42. int X=0,Y=0;
    43. int sum=0;
    44. for(int i=0;i<4;i++){
    45. X=x+fx[i];
    46. Y=y+fy[i];
    47. if(check(X,Y)){
    48. if(a[X][Y]=='.'){
    49. st[X][Y]=1;
    50. sum++;
    51. }
    52. else if(a[X][Y]=='x') continue;
    53. else if(a[X][Y]=='o'){
    54. sum+=dfs(X,Y);
    55. }
    56. }
    57. }
    58. return sum;
    59. }
    60. void solve(){
    61. num++;
    62. for(int i=1;i<=9;i++)
    63. for(int j=1;j<=9;j++)
    64. cin>>a[i][j];
    65. bool flag=false;
    66. for(int i=1;i<=9;i++)
    67. for(int j=1;j<=9;j++){
    68. if(a[i][j]=='o'){
    69. mem(st,0);
    70. int t=dfs(i,j);
    71. if(t==1){
    72. flag=true;
    73. break;
    74. }
    75. }
    76. }
    77. if(flag)
    78. printf("Case #%d: Can kill in one move!!!\n",num);
    79. else
    80. printf("Case #%d: Can not kill in one move!!!\n",num);
    81. }
    82. signed main(){
    83. int t;
    84. scanf("%d",&t);
    85. num=0;
    86. while(t--){
    87. //for(int i=1;i<=t;i++){
    88. solve();
    89. }
    90. }
    91. //made by melody 20220806

    H - Sudoku

    Yi Sima was one of the best counselors of Cao Cao. He likes to play a funny game himself. It looks like the modern Sudoku, but smaller.

    Actually, Yi Sima was playing it different. First of all, he tried to generate a 4×44×4 board with every row contains 1 to 4, every column contains 1 to 4. Also he made sure that if we cut the board into four 2×22×2 pieces, every piece contains 1 to 4.

    Then, he removed several numbers from the board and gave it to another guy to recover it. As other counselors are not as smart as Yi Sima, Yi Sima always made sure that the board only has one way to recover.

    Actually, you are seeing this because you've passed through to the Three-Kingdom Age. You can recover the board to make Yi Sima happy and be promoted. Go and do it!!!

    Input

    The first line of the input gives the number of test cases, T(1≤T≤100)T(1≤T≤100). TT test cases follow. Each test case starts with an empty line followed by 4 lines. Each line consist of 4 characters. Each character represents the number in the corresponding cell (one of '1', '2', '3', '4'). '*' represents that number was removed by Yi Sima.

    It's guaranteed that there will be exactly one way to recover the board.

    Output

    For each test case, output one line containing Case #x:, where xx is the test case number (starting from 1). Then output 4 lines with 4 characters each. indicate the recovered board.

    Sample

    InputcopyOutputcopy
     
    3 **** 2341 4123 3214 *243 *312 *421 *134 *41* **3* 2*41 4*2*
     
    Case #1: 1432 2341 4123 3214 Case #2: 1243 4312 3421 2134 Case #3: 3412 1234 2341 4123

     dfs

    1. #include
    2. using namespace std;
    3. const int N = 10;
    4. int mp[N][N];
    5. char s[N];
    6. int vis[N][N];
    7. int stx[N][N],sty[N][N];
    8. int flag;
    9. bool judge(int x,int y,int a)
    10. {
    11. if(x>=1&&x<=2)
    12. {
    13. if(y>=1&&y<=2)
    14. {
    15. if(mp[1][1]==a||mp[1][2]==a||mp[2][1]==a||mp[2][2]==a)
    16. return false;
    17. }
    18. else if(mp[1][3]==a||mp[1][4]==a||mp[2][3]==a||mp[2][4]==a)
    19. {
    20. return false;
    21. }
    22. }
    23. else
    24. {
    25. if(y>=1&&y<=2)
    26. {
    27. if(mp[3][1]==a||mp[3][2]==a||mp[4][1]==a||mp[4][2]==a)
    28. return false;
    29. }
    30. else if(mp[3][3]==a||mp[3][4]==a||mp[4][3]==a||mp[4][4]==a)
    31. return false;
    32. }
    33. return true;
    34. }
    35. void dfs(int x,int y)
    36. {
    37. if(flag)return ;
    38. else if(y>4)
    39. {
    40. for(int i=1; i<=4; i++)
    41. {
    42. for(int j=1; j<=4; j++)
    43. {
    44. printf("%d",mp[i][j]);
    45. }
    46. printf("\n");
    47. }
    48. flag=1;
    49. return ;
    50. }
    51. else if(x>4)dfs(1,y+1);
    52. else if(!mp[x][y])
    53. {
    54. for(int i=1; i<=4; ++i)
    55. {
    56. if(!stx[x][i]&&!sty[y][i]&&judge(x,y,i))
    57. {
    58. stx[x][i]=sty[y][i]=1;
    59. mp[x][y]=i;
    60. dfs(x+1,y);
    61. mp[x][y]=0;
    62. stx[x][i]=sty[y][i]=0;
    63. }
    64. }
    65. }
    66. else dfs(x+1,y);
    67. }
    68. int main()
    69. {
    70. int t,i,j,k=1;
    71. scanf("%d",&t);
    72. while(t--)
    73. {
    74. memset(stx,0,sizeof(stx));
    75. memset(sty,0,sizeof(sty));
    76. for(i=1; i<=4; i++)
    77. {
    78. scanf("%s",s);
    79. for(j=0; j<4; j++)
    80. {
    81. if(s[j]=='*')
    82. {
    83. mp[i][j+1]=0;
    84. }
    85. else
    86. {
    87. mp[i][j+1]=s[j]-'0';
    88. stx[i][mp[i][j+1]]=1;
    89. sty[j+1][mp[i][j+1]]=1;
    90. }
    91. }
    92. }
    93. flag=0;
    94. printf("Case #%d:\n",k++);
    95. dfs(1,1);
    96. }
    97. return 0;
    98. }

    L - Huatuo's Medicine

    Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these bottles together.

    However, there was a critical problem. When Huatuo arrived the patient's home, he took the chain out of his bag, and he could not recognize which bottle contains which type of medicine, but he remembers the order of the bottles on the chain.

    Huatuo has his own solution to resolve this problem. When he need to bring 2 types of medicines, E.g. AA and BB, he will put AA into one bottle and put BB into two bottles. Then he will chain the bottles in the order of '-B-A-B-'′−B−A−B−′. In this way, when he arrived the patient's home, he knew that the bottle in the middle is medicine AA and the bottle on two sides are medicine BB.

    Now you need to help Huatuo to work out what's the minimal number of bottles needed if he want to bring NN types of medicine.

    Input

    The first line of the input gives the number of test cases, T(1≤T≤100)T(1≤T≤100). TT lines follow. Each line consist of one integer N(1≤N≤100)N(1≤N≤100), the number of types of the medicine.

    Output

    For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the minimal number of bottles Huatuo needed.

    Sample

    InputcopyOutputcopy
     
    1 2
     
    Case #1: 3

    1. /*Where there is light, in my heart.*/
    2. /*SUMMER_TRAINING*/
    3. #include
    4. #include
    5. #include
    6. #include
    7. #include
    8. using namespace std;
    9. //
    10. #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    11. #define INF 0x3f3f3f
    12. #define ll long long
    13. #define INF 0x3f3f3f3f
    14. #define mem(a,b) memset(a,b,sizeof(a))
    15. #define unmap(a,b) unordered_map
    16. #define unset(a) unordered_set
    17. #define F first
    18. #define S second
    19. #define pb push_back
    20. #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
    21. #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
    22. #define mode 1e4+7
    23. #define pi acos(-1)
    24. #define U_queue priority_queue,greater >
    25. typedef double db;
    26. typedef pair<int,int> PII;
    27. typedef pair PLL;
    28. typedef vector<int> vi;
    29. const int N = 5010;
    30. //====================================================//
    31. signed main(){
    32. int t;
    33. scanf("%d",&t);
    34. //while(t--){
    35. for(int i=1;i<=t;i++){
    36. int n;
    37. cin>>n;
    38. int res=2*n-1;
    39. printf("Case #%d: %d\n",i,res);
    40. }
    41. }
    42. //made by melody 202208

    总结:C,D都没写出来,痛苦的点在于我们知道是dp,知道D是01背包但是需要改一下,大概是可以化成三维背包问题,然鹅 我和圆心都不会写dp,这个时候就很尴尬了。。

    不会的东西还是多,最近很懒散,属实有点累了hhh。。。

    补:

    D - Pick The Sticks

     

    The story happened long long ago. One day, Cao Cao made a special order called "Chicken Rib" to his army. No one got his point and all became very panic. However, Cao Cao himself felt very proud of his interesting idea and enjoyed it.

    Xiu Yang, one of the cleverest counselors of Cao Cao, understood the command Rather than keep it to himself, he told the point to the whole army. Cao Cao got very angry at his cleverness and would like to punish Xiu Yang. But how can you punish someone because he's clever? By looking at the chicken rib, he finally got a new idea to punish Xiu Yang.

    He told Xiu Yang that as his reward of encrypting the special order, he could take as many gold sticks as possible from his desk. But he could only use one stick as the container.

    Formally, we can treat the container stick as an LL length segment. And the gold sticks as segments too. There were many gold sticks with different length a_{i}ai​ and value v_{i}vi​. Xiu Yang needed to put these gold segments onto the container segment. No gold segment was allowed to be overlapped. Luckily, Xiu Yang came up with a good idea. On the two sides of the container, he could make part of the gold sticks outside the container as long as the center of the gravity of each gold stick was still within the container. This could help him get more valuable gold sticks.

    As a result, Xiu Yang took too many gold sticks which made Cao Cao much more angry. Cao Cao killed Xiu Yang before he made himself home. So no one knows how many gold sticks Xiu Yang made it in the container.

    Can you help solve the mystery by finding out what's the maximum value of the gold sticks Xiu Yang could have taken?

    Input

    The first line of the input gives the number of test cases, T(1≤T≤100)T(1≤T≤100). TT test cases follow. Each test case start with two integers, N(1≤N≤1000)N(1≤N≤1000) and L(1≤L≤2000)L(1≤L≤2000), represents the number of gold sticks and the length of the container stick. NN lines follow. Each line consist of two integers, a_{i}(1≤a_{i}≤2000)ai​(1≤ai​≤2000) and v_{i}(1≤v_{i}≤10^{9})vi​(1≤vi​≤109), represents the length and the value of the i_{th}ith​ gold stick.

    Output

    For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the maximum value of the gold sticks Xiu Yang could have taken.

    Sample

    InputcopyOutputcopy
     
    4 3 7 4 1 2 1 8 1 3 7 4 2 2 1 8 4 3 5 4 1 2 2 8 9 1 1 10 3
     
    Case #1: 2 Case #2: 6 Case #3: 11 Case #4: 3

    Hint


    In the third case, assume the container is lay on x-axis from 0 to 5. Xiu Yang could put the second gold stick center at 0 and put the third gold stick center at 5,
    so none of them will drop and he can get total 2+9=11 value.

    In the fourth case, Xiu Yang could just put the only gold stick center on any position of [0,1], and he can get the value of 3.

    1. /*Where there is light, in my heart.*/
    2. /*SUMMER_TRAINING*/
    3. #include
    4. #include
    5. #include
    6. #include
    7. #include
    8. using namespace std;
    9. //
    10. #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    11. #define ll long long
    12. #define INF 0x3f3f3f3f
    13. #define mem(a,b) memset(a,b,sizeof(a))
    14. #define unmap(a,b) unordered_map
    15. #define unset(a) unordered_set
    16. #define F first
    17. #define S second
    18. #define pb push_back
    19. #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
    20. #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
    21. #define mode 1e4+7
    22. #define pi acos(-1)
    23. #define U_queue priority_queue,greater >
    24. typedef double db;
    25. typedef pair<int,int> PII;
    26. typedef pair PLL;
    27. typedef vector<int> vi;
    28. const int N = 1e4+5;
    29. const int mod=1e9+7;
    30. //====================================================//
    31. int num;
    32. struct node{
    33. int w;
    34. ll v;
    35. }a[N];
    36. void solve(){
    37. num++;
    38. int n,m;
    39. cin>>n>>m;
    40. m*=2;
    41. ll Max=0;
    42. for(int i=0;i
    43. cin>>a[i].w>>a[i].v;
    44. a[i].w*=2;
    45. if(a[i].w>=2*m){
    46. Max=max(Max,a[i].v);
    47. }
    48. }
    49. ll dp[N][3];
    50. mem(dp,0);
    51. for(int i=0;i
    52. if(a[i].w>=2*m) continue;
    53. for(int j=m;j>=0;j--){
    54. for(int k=0;k<3;k++){
    55. if(j-a[i].w>=0){
    56. dp[j][k]=max(dp[j][k],dp[j-a[i].w][k]+a[i].v);
    57. }
    58. if(k&&a[i].w<=2*j){
    59. dp[j][k]=max(dp[j][k],dp[j-a[i].w/2][k-1]+a[i].v);
    60. }
    61. }
    62. }
    63. }
    64. ll ans=max(dp[m][0],dp[m][1]);
    65. ans=max(ans,dp[m][2]);
    66. printf("Case #%d: %lld\n",num,max(ans,Max));
    67. }
    68. signed main(){
    69. int t;
    70. scanf("%d",&t);
    71. num=0;
    72. while(t--){
    73. //for(int i=1;i<=t;i++){
    74. solve();
    75. }
    76. }
    77. //made by melody 20220806

  • 相关阅读:
    pyQt界面制作(登录+跳转页面)
    阿里云ECS部署Java项目使用docker安装MySQL
    C++ Reference: Standard C++ Library reference: C Library: cwchar: wcsncmp
    2022年程序员“生存报告”出炉,仅23%月薪不足1万,你在什么段位?
    【linux命令讲解大全】002. 使用locate更快速地查找文件
    VivadoAndTcl: synth_ip
    带宽储备能力超100 Tbps,华为云CDN保障平台从容应对流量高峰
    国庆作业 10月1 用select实现服务器并发
    Android Studio修改“choose boot runtime for the IDE“后无法打开
    Spring获取bean对象
  • 原文地址:https://blog.csdn.net/LanceLSf/article/details/126199831
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号