Submission #413772

# Submission time Handle Problem Language Result Execution time Memory
413772 2021-05-29T12:19:46 Z abdzag Comparing Plants (IOI20_plants) C++17
0 / 100
4000 ms 7452 KB
#include<bits/stdc++.h>
#include<unordered_map>
#include "plants.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define  sz(a) a.size()
typedef long double ld;
using namespace std;
static const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
vector<ll> sorted;
void init(int k, std::vector<int> r) {
	ll n = r.size();
	rep(i, 0, n) {
		ll indx = 0;
		rrep(j,n-1,-1){
			if (r[j] == 0) {
				indx = j;
				break;
			}
		}
		indx++;
		ll cur = 0;
		rep(j, 0, n) {
			cur++;
			if (r[(indx + j) % n] == 0) {
				if (cur > k) {
					indx = (j + indx) % n;
					break;
				}
				else cur = 1;
			}
		}
		r[indx] = inf;
		sorted.push_back(indx);
		indx -= (k-1);
		indx += n;
		rep(j, 0, k) {
			r[(indx + j) % n] -= 1;
		}
	}
	reverse(all(sorted));
}

int compare_plants(int x, int y) {
	if (find(all(sorted), x) - find(all(sorted), y) > 0)return 1;
	return -1;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:37:13: warning: overflow in conversion from 'long long int' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} changes value from '1000000000000000' to '-1530494976' [-Woverflow]
   37 |   r[indx] = inf;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 224 ms 4808 KB Output is correct
4 Execution timed out 4040 ms 7452 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -