Submission #300524

#TimeUsernameProblemLanguageResultExecution timeMemory
300524Pro100YanComparing Plants (IOI20_plants)C++14
5 / 100
110 ms7544 KiB
#include "plants.h"
#include <bits/stdc++.h>
#define ll long long

using namespace std;
const int N = 2e5 + 5;
ll pref[2 * N], n;

void init(int k, std::vector<int> r) {
    int l = n = r.size();
    for(int i = 0; i < n; i++)
        pref[i + 1] = pref[i] + r[i];
    for(int i = n; i < 2 * n; i++)
        pref[i + 1] = pref[i] + r[i - n];
	return;
}

int compare_plants(int x, int y) {
    if(pref[y] - pref[x] == y - x)
        return -1;
    else if(pref[x + n] - pref[y] == n + x - y)
        return 1;
    else if(pref[y] - pref[x] == 0)
        return 1;
    else if(pref[x + n] - pref[y] == 0)
        return -1;
	return 0;
}

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:13:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |     for(int i = n; i < 2 * n; i++)
      |     ^~~
plants.cpp:15:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   15 |  return;
      |  ^~~~~~
plants.cpp:10:9: warning: unused variable 'l' [-Wunused-variable]
   10 |     int l = n = r.size();
      |         ^
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:25:10: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   25 |     else if(pref[x + n] - pref[y] == 0)
      |          ^~
plants.cpp:27:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   27 |  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...