답안 #830479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830479 2023-08-19T07:04:23 Z Amylopectin Prize (CEOI22_prize) C++14
0 / 100
529 ms 165172 KB
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <vector>
using namespace std;
const int mxn = 2e6 + 10,mxm = 2e6 + 10;
vector<int> pat[2][mxn] = {};
int par[2][mxn] = {},he[2] = {},retva,retbn,retan,le[2] = {},ri[2] = {}
,up[2][25][mxn] = {},ju[2][25][mxn] = {},u[mxn] = {},las[2],ans[2];
int re(int v,int cn,int ro)
{
    int i,j,fn,can = -1,cbn = -1,cva = 0,of = 0;
    if(u[cn] == 1)
    {
        can = cn;
        cbn = cn;
        cva = 0;
    }
    for(i=0; i<pat[v][cn].size(); i++)
    {
        fn = pat[v][cn][i];
        re(v,fn,ro);
        if(retan != -1)
        {
            if(can == -1)
            {
                can = retan;
                cbn = retbn;
                cva = retva;
            }
            else 
            {
                of = 1;
                if(ro == 0)
                {
                    printf("? %d %d\n",can,retan);
                }
                else 
                {
                    scanf("%d %d %d %d",&le[0],&ri[0],&le[1],&ri[1]);
                    ju[v][0][cbn] = cn;
                    ju[v][0][retbn] = cn;
                    las[v] = cn;
                    up[v][0][cbn] = le[v] - cva;
                    up[v][0][retbn] = ri[v] - retva;
                }
            }
        }
    }
    if(of == 1)
    {
        retan = can;
        retva = cva + up[v][0][cbn];
        retbn = cn;
    }
    else 
    {
        retan = can;
        retva = cva;
        retbn = cbn;
    }
    return 0;
}
int main()
{
    int i,j,n,m,q,t,cn,cm,fn,fm,k;
    scanf("%d %d %d %d",&n,&m,&q,&t);
    for(i=0; i<2; i++)
    {
        for(j=1; j<=n; j++)
        {
            scanf("%d",&par[i][j]);
            if(par[i][j] == -1)
            {
                he[i] = j;
            }
            else 
            {
                pat[i][par[i][j]].push_back(j);
            }
        }
    }
    for(i=1; i<=m; i++)
    {
        printf("%d ",i);
        u[i] = 1;
    }
    printf("\n");
    for(i=0; i<q; i++)
    {
        printf("%d %d\n",1,1);
    }
    las[0] = 0;
    las[1] = 0;
    // re(0,he[0],0);
    // re(1,he[1],0);
    printf("!\n");
    fflush(stdout);
    fflush(stdin);
    for(i=0; i<q; i++)
    {
        scanf("%d %d %d %d",&cn,&cm,&fn,&fm);
    }
    // re(0,he[0],1);
    // re(1,he[1],1);
    // ju[0][0][las[0]] = -1;
    // ju[1][0][las[1]] = -1;
    // for(i=0; i<22; i++)
    // {
    //     for(j=1; j<=n; j++)
    //     {
    //         for(k=0; k<2; k++)
    //         {
    //             if(ju[k][i][j] == -1)
    //             {
    //                 ju[k][i+1][j] = -1;
    //                 up[k][i+1][j] = -1;
    //             } 
    //             else 
    //             {
    //                 ju[k][i+1][j] = ju[k][i][ju[k][i][j]];
    //                 up[k][i+1][j] = up[k][i][ju[k][i][j]] + up[k][i][j];
    //             }
    //         }
    //     }
    // }
    for(i=0; i<t; i++)
    {
        scanf("%d %d",&cn,&cm);
        // for(k=0; k<2; k++)
        // {
        //     ans[k] = 0;
        //     fn = cn;
        //     fm = cm;
        //     for(j=20; j>=0; j--)
        //     {
        //         if(ju[k][j][fn] != ju[k][j][fm])
        //         {
        //             ans[k] += up[k][j][fn] + up[k][j][fm];
        //             fn = ju[k][j][fn];
        //             fm = ju[k][j][fm];
        //         }
        //     }
        //     ans[k] += up[k][0][fn] + up[k][0][fm];
        // }
        printf("%d %d\n",ans[0],ans[1]);
    }
}

Compilation message

Main.cpp: In function 'int re(int, int, int)':
Main.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(i=0; i<pat[v][cn].size(); i++)
      |              ~^~~~~~~~~~~~~~~~~~
Main.cpp:13:11: warning: unused variable 'j' [-Wunused-variable]
   13 |     int i,j,fn,can = -1,cbn = -1,cva = 0,of = 0;
      |           ^
Main.cpp: In function 'int main()':
Main.cpp:67:33: warning: unused variable 'k' [-Wunused-variable]
   67 |     int i,j,n,m,q,t,cn,cm,fn,fm,k;
      |                                 ^
Main.cpp: In function 'int re(int, int, int)':
Main.cpp:41:26: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |                     scanf("%d %d %d %d",&le[0],&ri[0],&le[1],&ri[1]);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |     scanf("%d %d %d %d",&n,&m,&q,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:73:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |             scanf("%d",&par[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:103:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  103 |         scanf("%d %d %d %d",&cn,&cm,&fn,&fm);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:130:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  130 |         scanf("%d %d",&cn,&cm);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 281 ms 129692 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 273 ms 129800 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 232 ms 129476 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 529 ms 164644 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 516 ms 165172 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -