답안 #51585

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

#include <bits/stdc++.h>

using namespace std;

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

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

    	else ans += "1";
    }

    int ini = 0, 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 i = 1; i <= n; i++)
    {
    	if(make_test("0" + S)) S = "0" + S;

    	else S = "1" + S;
    }

    ini = 0, fim = S.size() - 1, mid, best;

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

    	string aux;

    	for(int i = mid; i < S.size(); i++) aux += S[i];

    	if(make_test(aux))
    	{    
    		best = mid;

    		fim = mid - 1;
    	}

    	else ini = mid + 1;
    }

    for(int i = best; i < S.size(); i++) resp += S[i];

    return resp;
}                       

Compilation message

dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:42:39: warning: right operand of comma operator has no effect [-Wunused-value]
     ini = 0, fim = S.size() - 1, mid, best;
                                       ^~~~
dna.cpp:42:43: warning: right operand of comma operator has no effect [-Wunused-value]
     ini = 0, fim = S.size() - 1, mid, best;
                                           ^
dna.cpp:50:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for(int i = mid; i < S.size(); i++) aux += S[i];
                       ~~^~~~~~~~~~
dna.cpp:62:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = best; i < S.size(); i++) resp += S[i];
                       ~~^~~~~~~~~~
dna.cpp:33: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 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 712 KB Output is correct
5 Correct 2 ms 712 KB Output is correct
6 Correct 2 ms 712 KB Output is correct
7 Correct 2 ms 712 KB Output is correct
8 Correct 2 ms 712 KB Output is correct
9 Correct 2 ms 712 KB Output is correct
10 Correct 2 ms 752 KB Output is correct
11 Correct 2 ms 752 KB Output is correct
12 Correct 2 ms 752 KB Output is correct
13 Correct 2 ms 752 KB Output is correct
14 Correct 2 ms 752 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 2 ms 752 KB Output is correct
17 Correct 2 ms 752 KB Output is correct
18 Correct 2 ms 752 KB Output is correct
19 Correct 2 ms 752 KB Output is correct
20 Correct 3 ms 752 KB Output is correct
21 Correct 2 ms 752 KB Output is correct
22 Correct 3 ms 752 KB Output is correct
23 Correct 3 ms 752 KB Output is correct
24 Correct 2 ms 824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 840 KB Output is correct
2 Correct 2 ms 840 KB Output is correct
3 Correct 2 ms 844 KB Output is correct
4 Correct 2 ms 848 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
6 Correct 2 ms 856 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 2 ms 864 KB Output is correct
9 Correct 2 ms 868 KB Output is correct
10 Correct 2 ms 872 KB Output is correct
11 Correct 2 ms 876 KB Output is correct
12 Correct 2 ms 880 KB Output is correct
13 Correct 2 ms 884 KB Output is correct
14 Correct 2 ms 888 KB Output is correct
15 Correct 2 ms 892 KB Output is correct
16 Correct 2 ms 896 KB Output is correct
17 Correct 3 ms 900 KB Output is correct
18 Correct 3 ms 904 KB Output is correct
19 Correct 2 ms 908 KB Output is correct
20 Correct 2 ms 912 KB Output is correct
21 Correct 3 ms 916 KB Output is correct
22 Correct 3 ms 920 KB Output is correct
23 Correct 3 ms 932 KB Output is correct
24 Correct 3 ms 932 KB Output is correct
25 Correct 3 ms 932 KB Output is correct
26 Correct 3 ms 944 KB Output is correct
27 Correct 3 ms 956 KB Output is correct
28 Correct 2 ms 972 KB Output is correct
29 Correct 3 ms 976 KB Output is correct
30 Correct 3 ms 984 KB Output is correct
31 Correct 3 ms 988 KB Output is correct
32 Correct 2 ms 992 KB Output is correct
33 Correct 3 ms 992 KB Output is correct
34 Correct 2 ms 1000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1096 KB Output is correct
2 Correct 2 ms 1096 KB Output is correct
3 Correct 2 ms 1096 KB Output is correct
4 Correct 3 ms 1096 KB Output is correct
5 Correct 2 ms 1096 KB Output is correct
6 Correct 2 ms 1096 KB Output is correct
7 Correct 2 ms 1096 KB Output is correct
8 Correct 2 ms 1096 KB Output is correct
9 Correct 2 ms 1096 KB Output is correct
10 Correct 2 ms 1096 KB Output is correct
11 Correct 2 ms 1096 KB Output is correct
12 Correct 2 ms 1096 KB Output is correct
13 Correct 2 ms 1096 KB Output is correct
14 Correct 2 ms 1096 KB Output is correct
15 Correct 2 ms 1096 KB Output is correct
16 Correct 2 ms 1096 KB Output is correct
17 Correct 3 ms 1096 KB Output is correct
18 Correct 2 ms 1096 KB Output is correct
19 Correct 2 ms 1096 KB Output is correct
20 Correct 2 ms 1180 KB Output is correct
21 Correct 2 ms 1180 KB Output is correct
22 Incorrect 32 ms 1208 KB Too many tests
23 Incorrect 26 ms 1216 KB Too many tests
24 Incorrect 27 ms 1252 KB Too many tests
25 Incorrect 28 ms 1256 KB Too many tests
26 Incorrect 27 ms 1260 KB Too many tests
27 Incorrect 23 ms 1264 KB Too many tests
28 Incorrect 23 ms 1268 KB Too many tests
29 Incorrect 24 ms 1272 KB Too many tests
30 Incorrect 27 ms 1276 KB Too many tests
31 Incorrect 28 ms 1284 KB Too many tests
32 Incorrect 29 ms 1284 KB Too many tests
33 Incorrect 23 ms 1292 KB Too many tests
34 Incorrect 23 ms 1296 KB Too many tests
35 Incorrect 23 ms 1300 KB Too many tests
36 Incorrect 20 ms 1304 KB Too many tests
37 Incorrect 21 ms 1436 KB Too many tests
38 Incorrect 25 ms 1436 KB Too many tests
39 Incorrect 25 ms 1556 KB Too many tests