Submission #959678

#TimeUsernameProblemLanguageResultExecution timeMemory
959678CadocTrener (COCI20_trener)C++14
0 / 110
77 ms75404 KiB
/* Author: Cadocx Codeforces: https://codeforces.com/profile/Kadoc VNOJ: oj.vnoi.info/user/Cadoc */ #include <bits/stdc++.h> using namespace std; // input/output #define fastIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define el cout << '\n' #define execute cerr << "Time elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << "s" // #pragma GCC optimize("O2") // #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") //data type #define ll long long #define ull unsigned long long #define pii pair<int, int> #define pll pair<ll, ll> #define piv pair<int, vector<int>> #define vi vector<int> #define vl vector<ll> #define vc vector<char> //STL #define sz(x) (int)(x).size() #define for1(i,l,r) for(auto i = l; i <= r; i++) #define for2(i,r,l) for(auto i = r; i >= l; i--) #define forin(i,a) for(auto i : a) #define pb push_back #define eb emplace_back #define pf push_front #define all(x) (x).begin(), (x).end() #define fi first #define se second //bitmask #define bitcnt(n) __builtin_popcount(n) #define mask(i) (1 << (i)) #define bit(n, i) (((n) >> (i)) & 1) #define set_on(n, i) ((n) | mask(i)) #define set_off(n, i) ((n) & ~mask(i)) //constant #define N 3000005 #define MOD 1000230007 #define INF 0x3f3f3f3f #define LINF 0x3f3f3f3f3f3f3f3f #define base 31 #define Kadoc 0 int n, k; ll f[N]; string s[55][1505]; vector<int> a[N]; map<string, int> mp; ll calc(int u){ if(!a[u].size() && (n-1)*k < u && u <= n*k) return f[u] = 1; if(f[u]) return f[u]; ll &ans = f[u]; for(int v:a[u]) ans += calc(v); return ans; } void solve(){ cin >> n >> k; for(int i=1; i<=n; ++i) for(int j=1; j<=k; ++j) cin >> s[i][j], mp[s[i][j]] = (i-1)*k + j; for(int i=1; i<=k; ++i) a[0].pb(i); for(int i=1; i<n; ++i) for(int j=1; j<=k; ++j){ for(char c='a'; c<='z'; ++c){ string t1 = s[i][j] + c, t2 = c + s[i][j]; if(mp.count(t1)) a[(i-1)*k + j].pb(mp[t1]); if(mp.count(t2)) a[(i-1)*k + j].pb(mp[t2]); } } for(int i=0; i<=n*k; ++i) a[i].resize(unique(all(a[i])) - a[i].begin()); calc(0); cout << f[0]; } int main(){ #define NAME "TASK" if(fopen(NAME".inp", "r")){ freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } fastIO; if(Kadoc){ int tc; cin >> tc; while(tc--){ solve(); } } else solve(); }

Compilation message (stderr)

trener.cpp: In function 'int main()':
trener.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen(NAME".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
trener.cpp:87:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |         freopen(NAME".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...