Submission #780892

# Submission time Handle Problem Language Result Execution time Memory
780892 2023-07-12T14:21:28 Z Josia Packing Biscuits (IOI20_biscuits) C++17
12 / 100
1 ms 596 KB
#include "biscuits.h"

#include <bits/stdc++.h>

using namespace std;

#define int long long

long long count_tastiness(long long x, std::vector<long long> a) {
	assert(x==1);
	vector<int> b(100, 0);


	int carry = 0;
	for (int i = 0; i<b.size(); i++) {
		carry /= 2;

		int here = carry+(i<a.size()?a[i]:0);

		if (here == 0) continue;

		if (here%2==0) {
			b[i] = 2;
			carry = here - 2;
		} else {
			b[i] = 1;
			carry = here - 1;
		}
	}

	int res = 1;

	bool cont = 1;

	// int lastCont = 0;

	int addup = 0;

	for (int i=0; i<62; i++) {
		if (!b[i]) {
			// lastCont = 0;
			res += addup;
			addup = 0;
			continue;
		}

		if (b[i] == 2) addup += res;
		res *= 2;
		// if (b[i] == 2) addup += 1<<lastCont;
		// lastCont ++;
	}

	res += addup;


	return res;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:15:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for (int i = 0; i<b.size(); i++) {
      |                  ~^~~~~~~~~
biscuits.cpp:18:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   int here = carry+(i<a.size()?a[i]:0);
      |                     ~^~~~~~~~~
biscuits.cpp:33:7: warning: unused variable 'cont' [-Wunused-variable]
   33 |  bool cont = 1;
      |       ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 340 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 340 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -