Submission #426090

# Submission time Handle Problem Language Result Execution time Memory
426090 2021-06-13T13:51:08 Z hhhhaura Cubeword (CEOI19_cubeword) C++14
50 / 100
265 ms 18148 KB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(signed i = a; i <= b; i++)
#define rrep(i, a, b) for(signed i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / (b))
#define all(x) x.begin(), x.end()

#define INF 1000000000000000000
#define eps (1e-9)

using namespace std;
#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
	const int P = 16, MOD = 998244353;
	signed cnt[11][70][70];
	int dp[11][70][70][70];
	set<string> st;
	void init_() { 
		st.clear();
	}
	int solve() {
		int x = 0;
		rep(len, 3, 10) rep(a, 0, P - 1) 
			rep(b, a, P - 1) rep(c, b, P - 1) {
				int cur = 0;
				rep(d, 0, P - 1) {
					cur += cnt[len][d][a] * cnt[len][d][b] % MOD
						*cnt[len][d][c] % MOD; x++;
				}			
				cur %= MOD; 
				dp[len][a][b][c] = dp[len][b][c][a] 
					= dp[len][c][b][a] = dp[len][a][c][b]
					= dp[len][c][a][b] = dp[len][b][a][c] = cur;
			}
		int ans = 0;
		rep(len, 3, 10) rep(a, 0, P - 1) rep(b, 0, P - 1) { 
			rep(c, 0, P - 1) rep(d, 0, P - 1) {
				ans = ans + (dp[len][a][b][d] * dp[len][a][b][c] % MOD
					* dp[len][a][c][d] % MOD * dp[len][b][c][d] % MOD);
				x++;
			}
			ans %= MOD;
		}
		assert(x <= 1e7);
		return ans;
	}
	void add(string s) {
		int sz = s.size(), pre, suf;
		if(isdigit(s[0])) pre = 52 + s[0] - '0';
		if(islower(s[0])) pre = s[0] - 'a';
		if(isupper(s[0])) pre = s[0] - 'A' + 26; 
		
		if(isdigit(s.back())) suf = 52 + s.back() - '0';
		if(islower(s.back())) suf = s.back() - 'a';
		if(isupper(s.back())) suf = s.back() - 'A' + 26; 
		cnt[sz][pre][suf] ++;
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n; cin >> n;
	init_();
	rep(i, 1, n) {
		string s, s1; cin >> s;
		int sz = s.size();
		if(st.find(s) == st.end()) add(s);
		st.insert(s);
		s1 = s, reverse(all(s1));
		if(st.find(s1) == st.end()) add(s1);
		st.insert(s1);
	}
	cout << solve() << "\n";
	return 0;
} 

Compilation message

cubeword.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
cubeword.cpp:22:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   22 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
cubeword.cpp:22:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   22 | void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
cubeword.cpp: In function 'int main()':
cubeword.cpp:82:7: warning: unused variable 'sz' [-Wunused-variable]
   82 |   int sz = s.size();
      |       ^~
cubeword.cpp: In function 'void solver::add(std::string)':
cubeword.cpp:72:19: warning: 'suf' may be used uninitialized in this function [-Wmaybe-uninitialized]
   72 |   cnt[sz][pre][suf] ++;
      |   ~~~~~~~~~~~~~~~~^
cubeword.cpp:72:19: warning: 'pre' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 259 ms 16700 KB Output is correct
2 Correct 206 ms 17184 KB Output is correct
3 Correct 231 ms 17272 KB Output is correct
4 Correct 246 ms 17220 KB Output is correct
5 Correct 224 ms 17300 KB Output is correct
6 Correct 242 ms 17232 KB Output is correct
7 Correct 241 ms 17252 KB Output is correct
8 Correct 207 ms 17300 KB Output is correct
9 Correct 238 ms 17220 KB Output is correct
10 Correct 220 ms 17236 KB Output is correct
11 Correct 219 ms 17308 KB Output is correct
12 Correct 228 ms 17204 KB Output is correct
13 Correct 219 ms 17216 KB Output is correct
14 Correct 230 ms 17380 KB Output is correct
15 Correct 229 ms 17284 KB Output is correct
16 Correct 218 ms 17220 KB Output is correct
17 Correct 223 ms 17276 KB Output is correct
18 Correct 240 ms 17272 KB Output is correct
19 Correct 197 ms 17208 KB Output is correct
20 Correct 231 ms 17224 KB Output is correct
21 Correct 245 ms 17224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 259 ms 16700 KB Output is correct
2 Correct 206 ms 17184 KB Output is correct
3 Correct 231 ms 17272 KB Output is correct
4 Correct 246 ms 17220 KB Output is correct
5 Correct 224 ms 17300 KB Output is correct
6 Correct 242 ms 17232 KB Output is correct
7 Correct 241 ms 17252 KB Output is correct
8 Correct 207 ms 17300 KB Output is correct
9 Correct 238 ms 17220 KB Output is correct
10 Correct 220 ms 17236 KB Output is correct
11 Correct 219 ms 17308 KB Output is correct
12 Correct 228 ms 17204 KB Output is correct
13 Correct 219 ms 17216 KB Output is correct
14 Correct 230 ms 17380 KB Output is correct
15 Correct 229 ms 17284 KB Output is correct
16 Correct 218 ms 17220 KB Output is correct
17 Correct 223 ms 17276 KB Output is correct
18 Correct 240 ms 17272 KB Output is correct
19 Correct 197 ms 17208 KB Output is correct
20 Correct 231 ms 17224 KB Output is correct
21 Correct 245 ms 17224 KB Output is correct
22 Correct 198 ms 17880 KB Output is correct
23 Correct 207 ms 17860 KB Output is correct
24 Correct 242 ms 17888 KB Output is correct
25 Correct 215 ms 17860 KB Output is correct
26 Correct 223 ms 17824 KB Output is correct
27 Correct 245 ms 17876 KB Output is correct
28 Correct 200 ms 17904 KB Output is correct
29 Correct 214 ms 17852 KB Output is correct
30 Correct 228 ms 17916 KB Output is correct
31 Correct 203 ms 17784 KB Output is correct
32 Correct 243 ms 17784 KB Output is correct
33 Correct 242 ms 17856 KB Output is correct
34 Correct 195 ms 17868 KB Output is correct
35 Correct 220 ms 17876 KB Output is correct
36 Correct 265 ms 17804 KB Output is correct
37 Correct 217 ms 17900 KB Output is correct
38 Correct 226 ms 17980 KB Output is correct
39 Correct 233 ms 17884 KB Output is correct
40 Correct 210 ms 17892 KB Output is correct
41 Correct 243 ms 18012 KB Output is correct
42 Correct 258 ms 17860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 259 ms 16700 KB Output is correct
2 Correct 206 ms 17184 KB Output is correct
3 Correct 231 ms 17272 KB Output is correct
4 Correct 246 ms 17220 KB Output is correct
5 Correct 224 ms 17300 KB Output is correct
6 Correct 242 ms 17232 KB Output is correct
7 Correct 241 ms 17252 KB Output is correct
8 Correct 207 ms 17300 KB Output is correct
9 Correct 238 ms 17220 KB Output is correct
10 Correct 220 ms 17236 KB Output is correct
11 Correct 219 ms 17308 KB Output is correct
12 Correct 228 ms 17204 KB Output is correct
13 Correct 219 ms 17216 KB Output is correct
14 Correct 230 ms 17380 KB Output is correct
15 Correct 229 ms 17284 KB Output is correct
16 Correct 218 ms 17220 KB Output is correct
17 Correct 223 ms 17276 KB Output is correct
18 Correct 240 ms 17272 KB Output is correct
19 Correct 197 ms 17208 KB Output is correct
20 Correct 231 ms 17224 KB Output is correct
21 Correct 245 ms 17224 KB Output is correct
22 Correct 198 ms 17880 KB Output is correct
23 Correct 207 ms 17860 KB Output is correct
24 Correct 242 ms 17888 KB Output is correct
25 Correct 215 ms 17860 KB Output is correct
26 Correct 223 ms 17824 KB Output is correct
27 Correct 245 ms 17876 KB Output is correct
28 Correct 200 ms 17904 KB Output is correct
29 Correct 214 ms 17852 KB Output is correct
30 Correct 228 ms 17916 KB Output is correct
31 Correct 203 ms 17784 KB Output is correct
32 Correct 243 ms 17784 KB Output is correct
33 Correct 242 ms 17856 KB Output is correct
34 Correct 195 ms 17868 KB Output is correct
35 Correct 220 ms 17876 KB Output is correct
36 Correct 265 ms 17804 KB Output is correct
37 Correct 217 ms 17900 KB Output is correct
38 Correct 226 ms 17980 KB Output is correct
39 Correct 233 ms 17884 KB Output is correct
40 Correct 210 ms 17892 KB Output is correct
41 Correct 243 ms 18012 KB Output is correct
42 Correct 258 ms 17860 KB Output is correct
43 Incorrect 219 ms 18148 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 259 ms 16700 KB Output is correct
2 Correct 206 ms 17184 KB Output is correct
3 Correct 231 ms 17272 KB Output is correct
4 Correct 246 ms 17220 KB Output is correct
5 Correct 224 ms 17300 KB Output is correct
6 Correct 242 ms 17232 KB Output is correct
7 Correct 241 ms 17252 KB Output is correct
8 Correct 207 ms 17300 KB Output is correct
9 Correct 238 ms 17220 KB Output is correct
10 Correct 220 ms 17236 KB Output is correct
11 Correct 219 ms 17308 KB Output is correct
12 Correct 228 ms 17204 KB Output is correct
13 Correct 219 ms 17216 KB Output is correct
14 Correct 230 ms 17380 KB Output is correct
15 Correct 229 ms 17284 KB Output is correct
16 Correct 218 ms 17220 KB Output is correct
17 Correct 223 ms 17276 KB Output is correct
18 Correct 240 ms 17272 KB Output is correct
19 Correct 197 ms 17208 KB Output is correct
20 Correct 231 ms 17224 KB Output is correct
21 Correct 245 ms 17224 KB Output is correct
22 Correct 198 ms 17880 KB Output is correct
23 Correct 207 ms 17860 KB Output is correct
24 Correct 242 ms 17888 KB Output is correct
25 Correct 215 ms 17860 KB Output is correct
26 Correct 223 ms 17824 KB Output is correct
27 Correct 245 ms 17876 KB Output is correct
28 Correct 200 ms 17904 KB Output is correct
29 Correct 214 ms 17852 KB Output is correct
30 Correct 228 ms 17916 KB Output is correct
31 Correct 203 ms 17784 KB Output is correct
32 Correct 243 ms 17784 KB Output is correct
33 Correct 242 ms 17856 KB Output is correct
34 Correct 195 ms 17868 KB Output is correct
35 Correct 220 ms 17876 KB Output is correct
36 Correct 265 ms 17804 KB Output is correct
37 Correct 217 ms 17900 KB Output is correct
38 Correct 226 ms 17980 KB Output is correct
39 Correct 233 ms 17884 KB Output is correct
40 Correct 210 ms 17892 KB Output is correct
41 Correct 243 ms 18012 KB Output is correct
42 Correct 258 ms 17860 KB Output is correct
43 Incorrect 219 ms 18148 KB Output isn't correct
44 Halted 0 ms 0 KB -