제출 #1305299

#제출 시각아이디문제언어결과실행 시간메모리
1305299StefanSebezCubeword (CEOI19_cubeword)C++20
100 / 100
598 ms8600 KiB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
const int N=62,mod=998244353;
map<char,int>mapa;
ll cnt[N+1][N+1],dp[N+1][N+1][N+1];
vector<string>S[11];
int main(){
    int nc=0;
    for(char c='a';c<='z';c++)mapa[c]=++nc;
    for(char c='A';c<='Z';c++)mapa[c]=++nc;
    for(char c='0';c<='9';c++)mapa[c]=++nc;
    int n;scanf("%i",&n);
    for(int i=1;i<=n;i++){
        string s;cin>>s;
        S[s.size()].pb(s);
    }
    ll res=0;
    for(int d=3;d<=10;d++){
        for(int i=1;i<=N;i++)for(int j=1;j<=N;j++)cnt[i][j]=0;
        map<string,bool>mapa1;
        for(auto s:S[d]){
            int x=mapa[s[0]],y=mapa[s.back()];
            if(!mapa1[s])cnt[x][y]++,mapa1[s]=true;
            reverse(s.begin(),s.end());
            if(!mapa1[s])cnt[y][x]++,mapa1[s]=true;
        }
        for(int i=1;i<=N;i++){
            for(int j=i;j<=N;j++){
                for(int k=j;k<=N;k++){
                    dp[i][j][k]=0;
                    for(int l=1;l<=N;l++){
                        dp[i][j][k]+=cnt[i][l]*cnt[j][l]%mod*cnt[k][l]%mod;
                    }
                    dp[i][j][k]%=mod;
                    dp[i][k][j]=dp[j][i][k]=dp[j][k][i]=dp[k][i][j]=dp[k][j][i]=dp[i][j][k];
                }
            }
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                for(int k=1;k<=N;k++){
                    for(int l=1;l<=N;l++){
                        res+=dp[i][j][k]*dp[i][j][l]%mod*dp[i][k][l]%mod*dp[j][k][l]%mod;
                    }
                }
            }
        }
        res%=mod;
    }
    printf("%lld\n",res);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

cubeword.cpp: In function 'int main()':
cubeword.cpp:18:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     int n;scanf("%i",&n);
      |           ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...