제출 #348463

#제출 시각아이디문제언어결과실행 시간메모리
348463daniel920712Jousting tournament (IOI12_tournament)C++14
49 / 100
1084 ms1132 KiB
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <stdio.h>
#include <assert.h>
#include <vector>
using namespace std;
vector < int > all;
vector < int > ttt;


int GetBestPosition(int N, int C, int R, int *K, int *S, int *E)
{
    int ans=-1,where=-1,who,i,j,k,tt,big,how=0,con=0,x,y,z;
    for(i=0;i<N;i++)
    {
        tt=0;

        all.clear();
        for(j=0;j<i;j++) all.push_back(K[j]);
        all.push_back(R);
        for(j=i;j<N-1;j++) all.push_back(K[j]);

        x=-1;
        y=2e9;
        z=i;
        for(j=0;j<N;j++)
        {
            //printf("%d ",all[j]);
            if(all[j]>R)
            {
                if(j<i) x=max(x,j);
                else y=min(y,j);
            }
        }
        //printf("\n%d %d %d\n",x,y,z);

        for(j=0;j<C;j++)
        {
            if(S[j]<=z&&E[j]>=z)
            {
                if(S[j]<=x||E[j]>=y) break;
                else
                {
                    tt++;
                    z=S[j];
                    y-=(E[j]-S[j]);
                }
            }
            else if(E[j]<z)
            {
                if(S[j]<=x&&E[j]>=x)
                {
                    x=S[j];
                    y-=(E[j]-S[j]);
                    z-=(E[j]-S[j]);
                }
                else if(x>E[j])
                {
                    x-=(E[j]-S[j]);
                    y-=(E[j]-S[j]);
                    z-=(E[j]-S[j]);
                }
                else
                {
                    y-=(E[j]-S[j]);
                    z-=(E[j]-S[j]);
                }
            }
            else
            {
                if(S[j]<=y&&E[j]>=y) y=S[j];
                else if(y>E[j]) y-=(E[j]-S[j]);
            }
        }
        //printf("%d %d\n",i,tt);
        if(tt>ans)
        {

            ans=tt;
            where=i;
        }

    }

    return where;

}

컴파일 시 표준 에러 (stderr) 메시지

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:14:25: warning: unused variable 'who' [-Wunused-variable]
   14 |     int ans=-1,where=-1,who,i,j,k,tt,big,how=0,con=0,x,y,z;
      |                         ^~~
tournament.cpp:14:33: warning: unused variable 'k' [-Wunused-variable]
   14 |     int ans=-1,where=-1,who,i,j,k,tt,big,how=0,con=0,x,y,z;
      |                                 ^
tournament.cpp:14:38: warning: unused variable 'big' [-Wunused-variable]
   14 |     int ans=-1,where=-1,who,i,j,k,tt,big,how=0,con=0,x,y,z;
      |                                      ^~~
tournament.cpp:14:42: warning: unused variable 'how' [-Wunused-variable]
   14 |     int ans=-1,where=-1,who,i,j,k,tt,big,how=0,con=0,x,y,z;
      |                                          ^~~
tournament.cpp:14:48: warning: unused variable 'con' [-Wunused-variable]
   14 |     int ans=-1,where=-1,who,i,j,k,tt,big,how=0,con=0,x,y,z;
      |                                                ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...