Submission #1190690

#TimeUsernameProblemLanguageResultExecution timeMemory
1190690alexander707070Tricolor Lights (JOI24_tricolor)C++20
10 / 100
2000 ms2952 KiB
#include<bits/stdc++.h>
#include "Anna.h"
using namespace std;

mt19937 rng(42069);

namespace Anna{
    int L;

    string s;
    int n;

    char letter(int x){
        if(x==0)return 'R';
        if(x==1)return 'G';
        if(x==2)return 'B';
    }

    char diff(char x){
        if(x=='R')return 'G';
        if(x=='G')return 'B';
        if(x=='B')return 'R';
    }

    void gen(){
        for(int i=1;i<=n;i++){
            s.push_back(letter(rng()%3));
        }
    }
};

pair<string, int> anna(int N, string S){
    using namespace Anna;

    n=N;
    gen();

    for(int i=0;i<n;i++){
        if(s[i]==S[i]){
            s[i]=diff(S[i]);
        }
    }

    L=min(n,130);
    return {s,L};
}
#include<bits/stdc++.h>
#include "Bruno.h"
using namespace std;

mt19937 rnd(42069);

namespace Bruno{
    int L;
    
    string s;
    int n;
    unordered_map<string,int> mp;

    char letter(int x){
        if(x==0)return 'R';
        if(x==1)return 'G';
        if(x==2)return 'B';
    }

    char diff(char x){
        if(x=='R')return 'G';
        if(x=='G')return 'B';
        if(x=='B')return 'R';
    }

    void gen(){
        for(int i=1;i<=n;i++){
            s.push_back(letter(rnd()%3));
        }
    }
};

void init(int N, int l){
    using namespace Bruno;

    n=N; L=l;
    gen();
}

int bruno(string u){
    using namespace Bruno;

    if(mp[u]>0)return mp[u];

    int best=0,pos=0,sbest=0;
    for(int i=0;i<n-L+1;i++){
        int cnt=0;
        for(int f=i;f<i+L;f++){
            if(u[f-i]==s[f])cnt++;
        }

        if(cnt>best){
            sbest=best;

            best=cnt; 
            pos=i;
        }

        if(best>115)break;
    }

    for(int f=pos;f<pos+L;f++)s[f]=u[f-pos];

    mp[u]=pos+1;
    return pos+1;
}

Compilation message (stderr)

# 1번째 컴파일 단계

Anna.cpp: In function 'char Anna::letter(int)':
Anna.cpp:17:5: warning: control reaches end of non-void function [-Wreturn-type]
   17 |     }
      |     ^
Anna.cpp: In function 'char Anna::diff(char)':
Anna.cpp:23:5: warning: control reaches end of non-void function [-Wreturn-type]
   23 |     }
      |     ^

# 2번째 컴파일 단계

Bruno.cpp: In function 'char Bruno::letter(int)':
Bruno.cpp:18:5: warning: control reaches end of non-void function [-Wreturn-type]
   18 |     }
      |     ^
Bruno.cpp: In function 'char Bruno::diff(char)':
Bruno.cpp:24:5: warning: control reaches end of non-void function [-Wreturn-type]
   24 |     }
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...