답안 #1027678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027678 2024-07-19T08:59:33 Z earlyamazon Savez (COCI15_savez) C++14
0 / 120
27 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int mn = 2e6+7;
const int mod1 = 1e9+7;
const int mod2 = 1e9+9;
const int p1 = 269;
const int p2 = 271;
int n,wyn;
string t[mn];
vector<pair<int,int>> hpref[mn];
map<pair<int,int>, int> dp;
pair<int,int> pot[mn];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    pot[0] = {1,1};
    for (int i = 1; i < mn; i++){
        pot[i] = {pot[i-1].first*p1%mod1, pot[i-1].second*p2%mod2};
    }
    for (int i = 0; i < n; i++){
        cin>>t[i];
        hpref[i].push_back({0, 0});
        for (int j = 1; j <= t[i].size(); j++){
            hpref[i].push_back({(hpref[i].back().first*p1+t[i][j-1])%mod1, (hpref[i].back().second*p2+t[i][j-1])%mod2});
        }
        int mx = 0;
        for (int j = 1; j <= t[i].size(); j++){
            pair<int,int> h = hpref[i][j];
            if (h == make_pair((hpref[i][t[i].size()].first-((hpref[i][t[i].size()-j].first*pot[j].first)%mod1)+mod1)%mod1, (hpref[i][t[i].size()].second-((hpref[i][t[i].size()-j].second*pot[j].second)%mod2)+mod2)%mod2)){
                mx = max(mx, dp[h]);
            }
        }
        mx++;
        wyn = max(wyn, mx);
        dp[hpref[i].back()] = mx;
        cout<<hpref[i].size()<<" "<<hpref[i].back().first<<" "<<hpref[i].back().second<<" "<<mx<<"\n";
    }
    cout<<wyn<<"\n";
}

Compilation message

savez.cpp: In function 'int32_t main()':
savez.cpp:27:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for (int j = 1; j <= t[i].size(); j++){
      |                         ~~^~~~~~~~~~~~~~
savez.cpp:31:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int j = 1; j <= t[i].size(); j++){
      |                         ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 27 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 27 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 27 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 25 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -