제출 #1259747

#제출 시각아이디문제언어결과실행 시간메모리
1259747AndreasK식물 비교 (IOI20_plants)C++20
5 / 100
49 ms6596 KiB
#include <bits/stdc++.h>
#include "plants.h"
using namespace std;

#define designed ios_base::sync_with_stdio(0);
#define by cin.tie(0);
#define AndreasK cout.tie(0);
//#define int long long
#define akinput freopen("akinput.txt", "r", stdin);
#define akoutput freopen("akoutput.txt", "w", stdout);

int f;
vector<int> rr;
vector<int> pre;

void init(int k, std::vector<int> r) {
    f = r.size();
    rr.resize(r.size() + 1);
    for (int c = 1; c <= r.size(); c++)
        rr[c] = r[c - 1];
    pre.assign(2 * r.size() + 1, 0);
    for (int c = 1; c <= r.size(); c++) {
        pre[c] = pre[c - 1] + rr[c];
    }
    for (int c = 1; c <= r.size(); c++) {
        pre[c + r.size()] = pre[c + r.size() - 1] + rr[c];
    }
	return;
}

int compare_plants(int x, int y) {
    x++;
    y++;
    int y2 = y;
    if (y2 < x)
        y2 += f;
    if (pre[y2 - 1] - pre[x - 1] == 0) {
        return 1;
    }
    else if (pre[y2 - 1] - pre[x - 1] == (y2 - 1 - (x - 1)))
        return -1;
    else {
        int x2 = x;
        if (x2 < y)
            x2 += f;
        if (pre[x2 - 1] - pre[y - 1] == 0) {
            return -1;
        }
        else if (pre[x2 - 1] - pre[y - 1] == (x2 - 1 - (y - 1)))
            return 1;
        else
            return 0;
    }
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...