답안 #51586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51586 2018-06-18T23:39:37 Z MatheusLealV Martian DNA (IOI16_dna) C++17
0 / 100
17 ms 640 KB
#include "dna.h"

#include <bits/stdc++.h>

using namespace std;

int bsearch1(int n)
{
	int ini = 1, fim = n, mid, best;

	while(fim >= ini)
	{
		mid = (ini + fim)/2;

		string aux;

		for(int i = 1; i <= mid; i++) aux += "0";

		if(make_test(aux)) best = mid, ini = mid + 1;

		else fim = mid - 1;
	}

	return best;
}

string analyse(int n, int t) 
{
    string ans, S, resp;

    int mz = bsearch1(n);

    for(int i = 0; i < mz; i++) ans += "0";

    for(int i = 1; i <= n - mz; i++)
    {
    	if(make_test(ans + "1")) ans += "1";

    	else
    	{
    		int qtdz = 0;

    		for(int j = ans.size() - 1; j >= 0; j--)
    		{
    			if(ans[j] != '0') break;

    			qtdz ++;
    		}

    		if(qtdz > mz) break;

    		ans += "0";
    	}
    }

    int ini = mz + 1, fim = n - 1, mid, best;

    while(fim >= ini)
    {
    	mid = (ini + fim)/2;

    	string aux;

    	for(int i = 0; i <= mid; i++) aux += ans[i];

    	if(make_test(aux)) best = mid, ini = mid + 1;

    	else fim = mid - 1;
    }

    for(int i = 0; i <= best; i++) S += ans[i];

    for(int resta = 1; resta < n - best; resta ++)
    {
    	if(make_test("1" + S)) S = "1" + S;

    	else S = "0" + S;
    }

    return S;
}                       

Compilation message

dna.cpp: In function 'int bsearch1(int)':
dna.cpp:24:9: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return best;
         ^~~~
dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:71:22: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
     for(int i = 0; i <= best; i++) S += ans[i];
                    ~~^~~~~~~
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 Incorrect 2 ms 248 KB Wrong DNA
2 Incorrect 3 ms 356 KB Wrong DNA
3 Incorrect 2 ms 432 KB Wrong DNA
4 Incorrect 2 ms 636 KB Wrong DNA
5 Incorrect 2 ms 636 KB Wrong DNA
6 Correct 2 ms 636 KB Output is correct
7 Incorrect 2 ms 636 KB Wrong DNA
8 Incorrect 2 ms 636 KB Wrong DNA
9 Correct 3 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Incorrect 2 ms 636 KB Wrong DNA
12 Correct 3 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Incorrect 3 ms 636 KB Wrong DNA
15 Correct 2 ms 636 KB Output is correct
16 Correct 2 ms 636 KB Output is correct
17 Incorrect 2 ms 636 KB Wrong DNA
18 Correct 2 ms 636 KB Output is correct
19 Incorrect 2 ms 636 KB Wrong DNA
20 Incorrect 2 ms 636 KB Wrong DNA
21 Incorrect 2 ms 636 KB Wrong DNA
22 Correct 3 ms 636 KB Output is correct
23 Correct 2 ms 636 KB Output is correct
24 Incorrect 2 ms 636 KB Wrong DNA
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 636 KB Wrong DNA
2 Incorrect 2 ms 636 KB Wrong DNA
3 Incorrect 2 ms 636 KB Wrong DNA
4 Incorrect 2 ms 636 KB Wrong DNA
5 Incorrect 3 ms 636 KB Wrong DNA
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 636 KB Output is correct
8 Correct 2 ms 636 KB Output is correct
9 Incorrect 2 ms 636 KB Wrong DNA
10 Incorrect 3 ms 636 KB Wrong DNA
11 Incorrect 2 ms 636 KB Wrong DNA
12 Correct 2 ms 636 KB Output is correct
13 Correct 3 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 636 KB Output is correct
16 Incorrect 3 ms 636 KB Wrong DNA
17 Correct 3 ms 636 KB Output is correct
18 Correct 3 ms 636 KB Output is correct
19 Correct 2 ms 636 KB Output is correct
20 Correct 2 ms 636 KB Output is correct
21 Correct 2 ms 636 KB Output is correct
22 Correct 2 ms 636 KB Output is correct
23 Correct 3 ms 636 KB Output is correct
24 Correct 2 ms 636 KB Output is correct
25 Correct 2 ms 636 KB Output is correct
26 Correct 3 ms 636 KB Output is correct
27 Incorrect 2 ms 636 KB Wrong DNA
28 Correct 2 ms 636 KB Output is correct
29 Correct 2 ms 636 KB Output is correct
30 Correct 3 ms 636 KB Output is correct
31 Correct 3 ms 636 KB Output is correct
32 Correct 2 ms 636 KB Output is correct
33 Correct 2 ms 636 KB Output is correct
34 Incorrect 2 ms 636 KB Wrong DNA
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 636 KB Wrong DNA
2 Incorrect 2 ms 636 KB Wrong DNA
3 Incorrect 2 ms 636 KB Wrong DNA
4 Incorrect 2 ms 636 KB Wrong DNA
5 Incorrect 2 ms 636 KB Wrong DNA
6 Correct 2 ms 636 KB Output is correct
7 Correct 2 ms 636 KB Output is correct
8 Correct 2 ms 636 KB Output is correct
9 Incorrect 2 ms 636 KB Wrong DNA
10 Incorrect 3 ms 636 KB Wrong DNA
11 Incorrect 2 ms 636 KB Wrong DNA
12 Correct 2 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 636 KB Output is correct
16 Incorrect 2 ms 636 KB Wrong DNA
17 Correct 3 ms 636 KB Output is correct
18 Correct 3 ms 636 KB Output is correct
19 Correct 2 ms 636 KB Output is correct
20 Correct 3 ms 636 KB Output is correct
21 Correct 3 ms 636 KB Output is correct
22 Correct 12 ms 636 KB Output is correct
23 Correct 16 ms 636 KB Output is correct
24 Correct 12 ms 636 KB Output is correct
25 Correct 17 ms 636 KB Output is correct
26 Correct 17 ms 636 KB Output is correct
27 Correct 9 ms 636 KB Output is correct
28 Correct 10 ms 636 KB Output is correct
29 Correct 13 ms 636 KB Output is correct
30 Correct 8 ms 636 KB Output is correct
31 Correct 13 ms 636 KB Output is correct
32 Incorrect 11 ms 636 KB Wrong DNA
33 Correct 12 ms 640 KB Output is correct
34 Correct 11 ms 640 KB Output is correct
35 Correct 10 ms 640 KB Output is correct
36 Correct 11 ms 640 KB Output is correct
37 Correct 10 ms 640 KB Output is correct
38 Correct 7 ms 640 KB Output is correct
39 Incorrect 11 ms 640 KB Wrong DNA