제출 #715646

#제출 시각아이디문제언어결과실행 시간메모리
715646arashMLGAnagramistica (COCI21_anagramistica)C++17
110 / 110
60 ms40336 KiB
#include<bits/stdc++.h> #ifdef LOCAL #include "Essentials/algo/debug.h" #else #define debug(...) 42 #endif using namespace std; //#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") typedef long long ll; typedef long double ldb; typedef pair<int,int> pii; typedef pair<ll,ll> pll; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 2e3 + 23; const ll mod = 1e9 + 7; const ll mod1 = 1006969; const ll B = 32323; const ll B2 = rng() % 100+ 27; const int LOG = 23; const ll inf = 1e18; #define F first #define S second #define pb push_back #define ms(x,y) memset((x) , (y) , sizeof (x)) #define done return cout<<endl , 0; #define kill(x) cout<<x<<endl, exit(0); #define isIn(x,s,e) ((x) >= (s) && (x) <= e) #define all(x) x.begin(),x.end() #define sz(x) (int)x.size() #define pc(x) __builtin_popcount(x) #define ctz(x) __builtin_ctz(x) #define MinHeap(x) priority_queue<x, vector<x> , greater<x> > #define MaxHeap(x) priority_queue<x, vector<x>> #define int ll ll pw(ll a, ll b, ll md = mod){ll res = 1; while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);} int get_hash(string s,int modd,int base) { int hsh =0; for(int i = 0; i < sz(s);i ++) { hsh = (hsh * base + s[i] - 'a' +1) % modd; } return hsh; } pll get_hash(string s) { return {get_hash(s,mod1,B), get_hash(s,mod,B2)}; } int n,k; vector<pll> v; int dp[N][N]; int c[N][N]; int32_t main() { cin.tie(nullptr)->sync_with_stdio(false); for(int i = 0 ;i < N; i++) { c[i][0] = 1; c[i][i] = 1; for(int j = 1; j < i ; j++) { c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod; } } cin>>n>>k; for(int i =0; i< n; i++) { string s; cin>>s; sort(all(s)); v.pb(get_hash(s)); } v.pb({-1,-1}); sort(all(v)); debug(v); int cnt = 0; dp[0][0] = 1; for(int i = 1; i<= n;i ++) { if(v[i] != v[i-1]) { cnt = 0; } for(int l = 0 ; l <= k ;l ++) { dp[i][l] = dp[i-1][l]; } for(int j = 0 ;j <= cnt; j ++) { for(int l = (j+1)*j/2 ; l <= k ;l ++) { (dp[i][l] += c[cnt][j] * dp[i-cnt-1][l - (j+1) * j /2]) %= mod; } } cnt++; } cout<<dp[n][k]; done; }

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

anagramistica.cpp: In function 'int32_t main()':
anagramistica.cpp:5:20: warning: statement has no effect [-Wunused-value]
    5 | #define debug(...) 42
      |                    ^~
anagramistica.cpp:79:5: note: in expansion of macro 'debug'
   79 |     debug(v);
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...