답안 #60273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60273 2018-07-23T23:41:26 Z kingpig9 Martian DNA (IOI16_dna) C++11
0 / 100
22 ms 1264 KB
#include <bits/stdc++.h>
#include "dna.h"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

string analyse (int n, int t) {
	//find zeroes max
	int lo = 0, hi = n + 1;
	while (hi - lo > 1) {
		int mid = (lo + hi) / 2;
		if (make_test(string(mid, '0'))) {
			lo = mid;
		} else {
			hi = mid;
		}
	}

	if (lo == n) {
		return string(n, '0');
	}
	if (lo == 0) {
		return string(n, '1');
	}

	int mxzero = lo;
	string ans(mxzero, '0');
	for (int i = 0; i < n - mxzero; i++) {
		if (make_test(ans + '1')) {
			ans += '1';
		} else {
			int end0 = 0;
			for (int j = ans.size() - 1; j >= 0; j--) {
				if (ans[j] != '0') {
					break;
				}
				end0++;
			}

			if (end0 > mxzero) {
				break;
			}
			ans += '0';
		}
	}

	lo = mxzero;
	hi = ans.size();
	while (hi - lo > 1) {
		int mid = (lo + hi) / 2;
		if (make_test(ans.substr(0, mid))) {
			lo = mid;
		} else {
			hi = mid;
		}
	}

	ans = ans.substr(0, lo);
	while (ans.size() < n) {
		if (make_test('1' + ans)) {
			ans = '1' + ans;
		} else {
			ans = '0' + ans;
		}
	}
	return ans;
}

Compilation message

dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:67:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (ans.size() < n) {
         ~~~~~~~~~~~^~~
grader.cpp: In function 'bool make_test(std::__cxx11::string)':
grader.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < p.size(); i++) {
                  ~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i <= ss.size(); i++) {
                  ~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (pr[i] == p.size()) {
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 360 KB Output is correct
4 Incorrect 2 ms 476 KB Wrong DNA
5 Correct 3 ms 588 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 3 ms 704 KB Output is correct
8 Correct 4 ms 704 KB Output is correct
9 Incorrect 3 ms 704 KB Wrong DNA
10 Correct 3 ms 752 KB Output is correct
11 Correct 3 ms 752 KB Output is correct
12 Incorrect 3 ms 752 KB Wrong DNA
13 Correct 3 ms 752 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
15 Correct 3 ms 760 KB Output is correct
16 Incorrect 2 ms 760 KB Wrong DNA
17 Correct 2 ms 760 KB Output is correct
18 Incorrect 3 ms 760 KB Wrong DNA
19 Correct 2 ms 760 KB Output is correct
20 Correct 3 ms 760 KB Output is correct
21 Correct 3 ms 760 KB Output is correct
22 Incorrect 3 ms 760 KB Wrong DNA
23 Incorrect 2 ms 760 KB Wrong DNA
24 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 3 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Incorrect 3 ms 760 KB Wrong DNA
5 Correct 2 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 3 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Incorrect 3 ms 760 KB Wrong DNA
12 Correct 2 ms 760 KB Output is correct
13 Correct 3 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 3 ms 760 KB Output is correct
17 Correct 3 ms 888 KB Output is correct
18 Correct 3 ms 888 KB Output is correct
19 Correct 3 ms 888 KB Output is correct
20 Correct 2 ms 888 KB Output is correct
21 Correct 4 ms 888 KB Output is correct
22 Incorrect 4 ms 888 KB Wrong DNA
23 Correct 4 ms 888 KB Output is correct
24 Correct 3 ms 888 KB Output is correct
25 Correct 2 ms 912 KB Output is correct
26 Incorrect 3 ms 912 KB Wrong DNA
27 Correct 3 ms 912 KB Output is correct
28 Correct 3 ms 912 KB Output is correct
29 Correct 2 ms 912 KB Output is correct
30 Correct 3 ms 912 KB Output is correct
31 Correct 3 ms 912 KB Output is correct
32 Correct 3 ms 912 KB Output is correct
33 Incorrect 3 ms 912 KB Wrong DNA
34 Correct 2 ms 912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 912 KB Output is correct
2 Correct 3 ms 912 KB Output is correct
3 Correct 3 ms 912 KB Output is correct
4 Incorrect 2 ms 964 KB Wrong DNA
5 Correct 2 ms 964 KB Output is correct
6 Correct 3 ms 964 KB Output is correct
7 Correct 3 ms 964 KB Output is correct
8 Correct 2 ms 964 KB Output is correct
9 Correct 3 ms 964 KB Output is correct
10 Correct 3 ms 964 KB Output is correct
11 Incorrect 3 ms 964 KB Wrong DNA
12 Incorrect 2 ms 1000 KB Wrong DNA
13 Correct 3 ms 1000 KB Output is correct
14 Incorrect 3 ms 1000 KB Wrong DNA
15 Correct 2 ms 1000 KB Output is correct
16 Correct 3 ms 1000 KB Output is correct
17 Correct 3 ms 1000 KB Output is correct
18 Correct 2 ms 1056 KB Output is correct
19 Correct 3 ms 1056 KB Output is correct
20 Correct 3 ms 1056 KB Output is correct
21 Correct 4 ms 1072 KB Output is correct
22 Correct 22 ms 1088 KB Output is correct
23 Correct 19 ms 1092 KB Output is correct
24 Correct 16 ms 1096 KB Output is correct
25 Correct 22 ms 1100 KB Output is correct
26 Correct 21 ms 1104 KB Output is correct
27 Incorrect 11 ms 1108 KB Wrong DNA
28 Correct 11 ms 1112 KB Output is correct
29 Correct 3 ms 1116 KB Output is correct
30 Correct 2 ms 1116 KB Output is correct
31 Incorrect 10 ms 1124 KB Wrong DNA
32 Correct 4 ms 1128 KB Output is correct
33 Correct 13 ms 1132 KB Output is correct
34 Correct 12 ms 1140 KB Output is correct
35 Correct 12 ms 1144 KB Output is correct
36 Correct 15 ms 1264 KB Output is correct
37 Correct 12 ms 1264 KB Output is correct
38 Incorrect 9 ms 1264 KB Wrong DNA
39 Correct 10 ms 1264 KB Output is correct