Submission #1332146

#TimeUsernameProblemLanguageResultExecution timeMemory
1332146neptunnsRima (COCI25_rima)C++20
50 / 50
1 ms344 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define int long long
#define maxn 1005
#define mi LLONG_MIN
#define ma LLONG_MAX
#define mod 1000000007
#define pb push_back
#define S second
#define F first
int b = 200;
int ans1, ans2, ans3;
int add(int x, int y){
    return (x + y) % mod;
}
int minus(int x, int y){
    return (x - y + mod) % mod;
}

int mult(int x, int y){
    return (x*y) % mod;
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n / 4; i++){
        vector<vector<int>> hash(4,vector<int>(k+1,0));
        vector<string> lasts(4);
        for(int j = 0 ; j < 4; j++){
            for(int c = 0 ; c < m; c++){
                string s;
                cin >> s;
                if(c == m - 1){
                    reverse(s.begin(),s.end());
                    lasts[j] = s;
                }
            }
            if(lasts[j].size() < k){continue;}
            for(int c = 1 ; c <= k; c++) hash[j][c] = add((mult(hash[j][c-1],b)),lasts[j][c-1]);
        }
        if(hash[2][k] &&hash[0][k]!=0&&hash[0][k] == hash[1][k] && hash[2][k] == hash[3][k]){
            ans1++;
        }
        if(hash[1][k] &&hash[0][k]!=0&&hash[0][k] == hash[2][k] && hash[1][k] == hash[3][k]){
            ans2++;
        }
        if(hash[2][k] &&hash[0][k]!=0&&hash[0][k] == hash[3][k] && hash[1][k] == hash[2][k]){
            ans3++;
        }
    }
    cout << ans1 <<" "<< ans2 <<" " << ans3;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...