답안 #300415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300415 2020-09-17T07:00:04 Z daniel920712 식물 비교 (IOI20_plants) C++14
5 / 100
146 ms 16016 KB
#include "plants.h"
#include <stdio.h>
#include <vector>
#include <utility>
using namespace std;
vector < pair < int , int > > con[200005];
vector < int > all;
int N;
void init(int k,vector<int> r)
{
    int a=0,b=0,i,j,ok=0;
    all=r;
    N=r.size();
    for(i=0;i<N;i++)
    {
        if(r[(i+N-1)%N]!=r[i])
        {
            b=0;
            a++;

            con[i].push_back(make_pair(a,0));
            for(j=(i+1)%N;r[(j+N-1)%N]==r[i];j=(j+1)%N)
            {
                if(j==N-1) ok=1;
                if(r[i]==0) b--;
                else b++;
                con[j].push_back(make_pair(a,b));
                //printf("%d %d %d\n",j,a,b);
            }
        }
    }
	return;
}

int compare_plants(int x, int y)
{
    for(auto i:con[x])
    {
        for(auto j:con[y])
        {
            if(i.first==j.first)
            {
                if(i.second<j.second) return -1;
                return 1;
            }
        }
    }

	return 0;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:11:21: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   11 |     int a=0,b=0,i,j,ok=0;
      |                     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 3 ms 4992 KB Output is correct
5 Correct 4 ms 4992 KB Output is correct
6 Correct 68 ms 7800 KB Output is correct
7 Correct 93 ms 8644 KB Output is correct
8 Correct 138 ms 16004 KB Output is correct
9 Correct 137 ms 15992 KB Output is correct
10 Correct 138 ms 16016 KB Output is correct
11 Correct 146 ms 15992 KB Output is correct
12 Correct 138 ms 15992 KB Output is correct
13 Correct 131 ms 15992 KB Output is correct
14 Correct 138 ms 15992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Incorrect 4 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Incorrect 4 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Incorrect 4 ms 4992 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Incorrect 4 ms 4992 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 5 ms 4992 KB Output is correct
4 Incorrect 4 ms 4992 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 4 ms 4992 KB Output is correct
3 Correct 3 ms 4992 KB Output is correct
4 Correct 3 ms 4992 KB Output is correct
5 Correct 4 ms 4992 KB Output is correct
6 Correct 68 ms 7800 KB Output is correct
7 Correct 93 ms 8644 KB Output is correct
8 Correct 138 ms 16004 KB Output is correct
9 Correct 137 ms 15992 KB Output is correct
10 Correct 138 ms 16016 KB Output is correct
11 Correct 146 ms 15992 KB Output is correct
12 Correct 138 ms 15992 KB Output is correct
13 Correct 131 ms 15992 KB Output is correct
14 Correct 138 ms 15992 KB Output is correct
15 Correct 3 ms 4992 KB Output is correct
16 Correct 3 ms 4992 KB Output is correct
17 Incorrect 4 ms 4992 KB Output isn't correct
18 Halted 0 ms 0 KB -