Submission #1039869

#TimeUsernameProblemLanguageResultExecution timeMemory
1039869parsadox2Comparing Plants (IOI20_plants)C++17
5 / 100
40 ms6652 KiB
#include "plants.h" #include <bits/stdc++.h> #define F first #define S second using namespace std; const int N = 2e5 + 10; int n , k , f[2][N]; vector <int> a; void init(int kk, vector<int> r) { a = r; k = kk; n = r.size(); f[0][n - 1] = -1; f[1][n - 1] = -1; f[a[n - 1]][n - 1] = n - 1; for(int i = n - 2 ; i >= 0 ; i--) { f[0][i] = f[0][i + 1]; f[1][i] = f[1][i + 1]; f[a[i]][i] = i; } for(int i = n - 1 ; i >= 0 ; i--) { if(f[0][i] == -1) f[0][i] = f[0][0]; if(f[1][i] == -1) f[1][i] = f[1][0]; } return; } int compare_plants(int x, int y) { int res = 1; if(x > y) { swap(x , y); res = -1; } int ans = 0; if(f[0][x] >= y || f[0][x] < x) { ans = res * -1; } else if(f[1][x] >= y || f[1][x] < x) { ans = res; } else if(f[0][y] >= x && f[0][y] < y) { ans = res; } else if(f[1][y] >= x && f[1][y] < y) ans = res * -1; return ans; }
#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...