답안 #484418

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484418 2021-11-03T09:32:04 Z Carmel_Ab1 Martian DNA (IOI16_dna) C++17
0 / 100
11 ms 440 KB
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
typedef vector<pi> vpi;

//typedef tree<ll, null_type, less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T> ostream& operator<<(ostream& os, vector<T>& a){os<<"[";for(int i=0; i<ll(a.size()); i++){os << a[i] << ((i!=ll(a.size()-1)?" ":""));}os << "]\n"; return os;}

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map

//#include "grader.cpp"
#include "dna.h"
string substr(string s,int l,int r){
    string ans;
    for(int i=l; i<=r; i++)
        ans+=s[i];
    return ans;
}
string analyse(int n, int t) {
    if(!make_test("0"))
        return string(n,'1');

    string ans;


    int l=0,r=n;
    while(l<=r){
        int m=(l+r)/2;
        if(make_test(string(m,'0')))
            ans=string(m,'0'),l=m+1;
        else
            r=m-1;
    }

    int mx=ans.size(),cur=0;

    while(ans.size()<n && cur<mx){
        char c='0';
        if(make_test(ans+c))
            ans+=c,cur=0;
        else
            ans+=('1'+'0'-c),cur++;
    }

    l=0,r=n-1;
    string x;
    while(l<=r){
        int m=(l+r)/2;
        if(make_test(substr(ans,0,m)))
            x=substr(ans,0,m),l=m+1;
        else
            r=m-1;
    }

    ans=x;
    while(ans.size()<n){
        if(make_test("0"+ans))
            ans="0"+ans;
        else
            ans="1"+ans;
    }
    return ans;

}

Compilation message

dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:60:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     while(ans.size()<n && cur<mx){
      |           ~~~~~~~~~~^~
dna.cpp:79:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |     while(ans.size()<n){
      |           ~~~~~~~~~~^~
grader.cpp: In function 'bool make_test(std::string)':
grader.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int i = 0; i < p.size(); i++) {
      |                  ~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int i = 1; i <= ss.size(); i++) {
      |                  ~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if (pr[i] == p.size()) {
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 0 ms 204 KB Wrong DNA
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Incorrect 0 ms 204 KB Wrong DNA
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Incorrect 0 ms 204 KB Wrong DNA
17 Correct 0 ms 204 KB Output is correct
18 Incorrect 0 ms 204 KB Wrong DNA
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 292 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 292 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 292 KB Wrong DNA
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Incorrect 0 ms 204 KB Wrong DNA
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Incorrect 0 ms 204 KB Wrong DNA
19 Incorrect 1 ms 288 KB Wrong DNA
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Incorrect 0 ms 204 KB Wrong DNA
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Incorrect 1 ms 204 KB Wrong DNA
27 Correct 1 ms 204 KB Output is correct
28 Incorrect 0 ms 204 KB Wrong DNA
29 Incorrect 0 ms 204 KB Wrong DNA
30 Incorrect 1 ms 204 KB Wrong DNA
31 Incorrect 1 ms 296 KB Wrong DNA
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 0 ms 204 KB Wrong DNA
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Wrong DNA
13 Incorrect 1 ms 204 KB Wrong DNA
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Incorrect 1 ms 204 KB Wrong DNA
19 Correct 0 ms 204 KB Output is correct
20 Incorrect 0 ms 204 KB Wrong DNA
21 Correct 1 ms 204 KB Output is correct
22 Incorrect 8 ms 332 KB Wrong DNA
23 Incorrect 9 ms 348 KB Wrong DNA
24 Incorrect 11 ms 332 KB Wrong DNA
25 Correct 11 ms 440 KB Output is correct
26 Correct 11 ms 332 KB Output is correct
27 Correct 7 ms 332 KB Output is correct
28 Incorrect 6 ms 332 KB Wrong DNA
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Incorrect 8 ms 332 KB Wrong DNA
32 Correct 1 ms 204 KB Output is correct
33 Correct 8 ms 384 KB Output is correct
34 Correct 8 ms 332 KB Output is correct
35 Correct 8 ms 332 KB Output is correct
36 Correct 7 ms 332 KB Output is correct
37 Correct 7 ms 332 KB Output is correct
38 Correct 5 ms 332 KB Output is correct
39 Correct 10 ms 292 KB Output is correct