답안 #1038337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1038337 2024-07-29T17:02:24 Z vjudge1 Cubeword (CEOI19_cubeword) C++17
21 / 100
518 ms 18768 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("popcnt")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using lld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int,int>;
using pll = pair<ll, ll>;
using vii = vector<ii>;
using vpll = vector<pll>;

#define endl '\n'
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()

#define fore(i,l,r) for(auto i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(auto i=r; i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)

bool cmin(int &a, int b){if(b<a){a=b;return 1;}return 0;}
bool cmax(int &a, int b){if(b>a){a=b;return 1;}return 0;}
void valid(ll in){cout<<((in)?"YES\n":"NO\n");}
ll lcm(ll a, ll b){return (a/gcd(a,b))*b;}
ll gauss(ll n){return (n*(n+1))/2;}
const int N =1e5+7,mod= 998244353;
string s[N];
vi act;
ll n,ans=0;
set<string> st[6][6][11];
void solve(int i){
    if(i==8){
        fore(tam, 3, 11){
            ll aux=1;
            fo(i,4)aux=(aux*sz(st[act[i]][act[(i+1)%4]][tam]))%mod;
            fo(i,4)aux=(aux*sz(st[act[i]][act[i+4]][tam]))%mod;
            fo(i,4)aux=(aux*sz(st[act[i+4]][act[(i+1)%4+4]][tam]))%mod;
            ans=(ans+aux)%mod;
        }
        return;
    }
    fo(v, 6){
        act.pb(v);
        solve(i+1);
        act.pop_back();
    }
}
void test_case(){
    cin>>n;
    fo(i,n){
        cin>>s[i];
        st[s[i][0]-'a'][s[i].back()-'a'][sz(s[i])].insert(s[i]);
        reverse(all(s[i]));
        st[s[i][0]-'a'][s[i].back()-'a'][sz(s[i])].insert(s[i]);
    }
    solve(0);
    cout<<ans<<endl;
}
int main(){cin.tie(0)->sync_with_stdio(0);
    int t=1;
    // cin >> t;
    while(t--)test_case();
}

Compilation message

cubeword.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("O3")
      | 
cubeword.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 508 ms 18768 KB Output is correct
2 Correct 489 ms 17908 KB Output is correct
3 Correct 482 ms 18000 KB Output is correct
4 Correct 474 ms 18000 KB Output is correct
5 Correct 513 ms 17956 KB Output is correct
6 Correct 498 ms 18140 KB Output is correct
7 Correct 508 ms 18000 KB Output is correct
8 Correct 499 ms 18004 KB Output is correct
9 Correct 502 ms 18260 KB Output is correct
10 Correct 491 ms 18076 KB Output is correct
11 Correct 485 ms 18004 KB Output is correct
12 Correct 473 ms 18276 KB Output is correct
13 Correct 483 ms 18000 KB Output is correct
14 Correct 518 ms 18072 KB Output is correct
15 Correct 494 ms 18004 KB Output is correct
16 Correct 489 ms 18056 KB Output is correct
17 Correct 510 ms 18004 KB Output is correct
18 Correct 475 ms 18000 KB Output is correct
19 Correct 507 ms 18052 KB Output is correct
20 Correct 498 ms 18072 KB Output is correct
21 Correct 497 ms 18004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 508 ms 18768 KB Output is correct
2 Correct 489 ms 17908 KB Output is correct
3 Correct 482 ms 18000 KB Output is correct
4 Correct 474 ms 18000 KB Output is correct
5 Correct 513 ms 17956 KB Output is correct
6 Correct 498 ms 18140 KB Output is correct
7 Correct 508 ms 18000 KB Output is correct
8 Correct 499 ms 18004 KB Output is correct
9 Correct 502 ms 18260 KB Output is correct
10 Correct 491 ms 18076 KB Output is correct
11 Correct 485 ms 18004 KB Output is correct
12 Correct 473 ms 18276 KB Output is correct
13 Correct 483 ms 18000 KB Output is correct
14 Correct 518 ms 18072 KB Output is correct
15 Correct 494 ms 18004 KB Output is correct
16 Correct 489 ms 18056 KB Output is correct
17 Correct 510 ms 18004 KB Output is correct
18 Correct 475 ms 18000 KB Output is correct
19 Correct 507 ms 18052 KB Output is correct
20 Correct 498 ms 18072 KB Output is correct
21 Correct 497 ms 18004 KB Output is correct
22 Runtime error 3 ms 6744 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 508 ms 18768 KB Output is correct
2 Correct 489 ms 17908 KB Output is correct
3 Correct 482 ms 18000 KB Output is correct
4 Correct 474 ms 18000 KB Output is correct
5 Correct 513 ms 17956 KB Output is correct
6 Correct 498 ms 18140 KB Output is correct
7 Correct 508 ms 18000 KB Output is correct
8 Correct 499 ms 18004 KB Output is correct
9 Correct 502 ms 18260 KB Output is correct
10 Correct 491 ms 18076 KB Output is correct
11 Correct 485 ms 18004 KB Output is correct
12 Correct 473 ms 18276 KB Output is correct
13 Correct 483 ms 18000 KB Output is correct
14 Correct 518 ms 18072 KB Output is correct
15 Correct 494 ms 18004 KB Output is correct
16 Correct 489 ms 18056 KB Output is correct
17 Correct 510 ms 18004 KB Output is correct
18 Correct 475 ms 18000 KB Output is correct
19 Correct 507 ms 18052 KB Output is correct
20 Correct 498 ms 18072 KB Output is correct
21 Correct 497 ms 18004 KB Output is correct
22 Runtime error 3 ms 6744 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 508 ms 18768 KB Output is correct
2 Correct 489 ms 17908 KB Output is correct
3 Correct 482 ms 18000 KB Output is correct
4 Correct 474 ms 18000 KB Output is correct
5 Correct 513 ms 17956 KB Output is correct
6 Correct 498 ms 18140 KB Output is correct
7 Correct 508 ms 18000 KB Output is correct
8 Correct 499 ms 18004 KB Output is correct
9 Correct 502 ms 18260 KB Output is correct
10 Correct 491 ms 18076 KB Output is correct
11 Correct 485 ms 18004 KB Output is correct
12 Correct 473 ms 18276 KB Output is correct
13 Correct 483 ms 18000 KB Output is correct
14 Correct 518 ms 18072 KB Output is correct
15 Correct 494 ms 18004 KB Output is correct
16 Correct 489 ms 18056 KB Output is correct
17 Correct 510 ms 18004 KB Output is correct
18 Correct 475 ms 18000 KB Output is correct
19 Correct 507 ms 18052 KB Output is correct
20 Correct 498 ms 18072 KB Output is correct
21 Correct 497 ms 18004 KB Output is correct
22 Runtime error 3 ms 6744 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -