답안 #203780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203780 2020-02-22T06:18:32 Z dndhk Cubeword (CEOI19_cubeword) C++14
50 / 100
315 ms 6984 KB
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const ll MOD = 998244353;
const int MAX_N = 100000;
const int MAX_K = 30;

int N;
vector<string> str[11];
set<string> st;
ll cnt[MAX_K+1][MAX_K+1];
ll cnt2[MAX_K+1][MAX_K+1][MAX_K+1];
int num[4];
string s;

ll ans = 0;

int calc(char c){
	if(c>='0' && c<='9'){
		return c-'0';
	}
	if(c>='A' && c<='Z'){
		return c-'A'+10;
	}
	if(c>='a' && c<='z'){
		return c-'a';
	}
}

void solve(){
	for(int i=0; i<MAX_K; i++){
		for(int j=0; j<MAX_K; j++){
			for(int k=0; k<MAX_K; k++){
				cnt2[i][j][k] = 0;
				for(int t=0; t<MAX_K; t++){
					cnt2[i][j][k] = (cnt2[i][j][k] + (cnt[i][t] * cnt[j][t] * cnt[k][t] % MOD)) %  MOD;
				}
			}
		}
	}
	for(int i=0; i<MAX_K; i++){
		for(int j=0; j<MAX_K; j++){
			for(int k=0; k<MAX_K; k++){
				for(int t=0; t<MAX_K; t++){
					ll d = cnt2[i][j][k]; d = (d * cnt2[i][j][t]) % MOD; d = (d * cnt2[i][k][t]) % MOD; d = (d * cnt2[j][k][t]) % MOD;
					//if(d!=0)	cout<<i<<" "<<j<<" "<<k<<" "<<t<<" "<<d<<endl;
					ans = (ans + d) % MOD;
				}
			}
		}
	}
}

int main(){
	scanf("%d", &N);
	for(int i=1; i<=N; i++){
		cin>>s;
		str[s.size()].pb(s);
	}
	for(int l=3; l<=10; l++){
		if(str[l].empty())	continue;
		st.clear();
		for(int j=0; j<MAX_K; j++){
			for(int k=0; k<MAX_K; k++){
				cnt[j][k] = 0;
			}
		}
		while(!str[l].empty()){
			s = str[l].back(); str[l].pop_back();
			if(st.find(s)==st.end()){
				st.insert(s);
				cnt[calc(s[0])][calc(s.back())]++;
			}
			for(int i=0; i<l/2; i++){
				char c = s[i]; s[i] = s[l-1-i]; s[l-1-i] = c;
			}
			if(st.find(s)==st.end()){
				st.insert(s);
				cnt[calc(s[0])][calc(s.back())]++;
			}
		}
 		solve();
	}
	printf("%lld", ans);
	return 0;
}

Compilation message

cubeword.cpp: In function 'int calc(char)':
cubeword.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
cubeword.cpp: In function 'int main()':
cubeword.cpp:61:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 315 ms 6728 KB Output is correct
2 Correct 301 ms 6760 KB Output is correct
3 Correct 300 ms 6724 KB Output is correct
4 Correct 292 ms 6716 KB Output is correct
5 Correct 298 ms 6856 KB Output is correct
6 Correct 288 ms 6640 KB Output is correct
7 Correct 289 ms 6724 KB Output is correct
8 Correct 287 ms 6804 KB Output is correct
9 Correct 292 ms 6700 KB Output is correct
10 Correct 303 ms 6764 KB Output is correct
11 Correct 292 ms 6756 KB Output is correct
12 Correct 297 ms 6984 KB Output is correct
13 Correct 285 ms 6728 KB Output is correct
14 Correct 289 ms 6744 KB Output is correct
15 Correct 297 ms 6876 KB Output is correct
16 Correct 293 ms 6772 KB Output is correct
17 Correct 297 ms 6924 KB Output is correct
18 Correct 299 ms 6732 KB Output is correct
19 Correct 292 ms 6784 KB Output is correct
20 Correct 300 ms 6808 KB Output is correct
21 Correct 286 ms 6732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 315 ms 6728 KB Output is correct
2 Correct 301 ms 6760 KB Output is correct
3 Correct 300 ms 6724 KB Output is correct
4 Correct 292 ms 6716 KB Output is correct
5 Correct 298 ms 6856 KB Output is correct
6 Correct 288 ms 6640 KB Output is correct
7 Correct 289 ms 6724 KB Output is correct
8 Correct 287 ms 6804 KB Output is correct
9 Correct 292 ms 6700 KB Output is correct
10 Correct 303 ms 6764 KB Output is correct
11 Correct 292 ms 6756 KB Output is correct
12 Correct 297 ms 6984 KB Output is correct
13 Correct 285 ms 6728 KB Output is correct
14 Correct 289 ms 6744 KB Output is correct
15 Correct 297 ms 6876 KB Output is correct
16 Correct 293 ms 6772 KB Output is correct
17 Correct 297 ms 6924 KB Output is correct
18 Correct 299 ms 6732 KB Output is correct
19 Correct 292 ms 6784 KB Output is correct
20 Correct 300 ms 6808 KB Output is correct
21 Correct 286 ms 6732 KB Output is correct
22 Correct 299 ms 6020 KB Output is correct
23 Correct 271 ms 5996 KB Output is correct
24 Correct 278 ms 5996 KB Output is correct
25 Correct 273 ms 5868 KB Output is correct
26 Correct 275 ms 5880 KB Output is correct
27 Correct 281 ms 6088 KB Output is correct
28 Correct 278 ms 5900 KB Output is correct
29 Correct 278 ms 5980 KB Output is correct
30 Correct 278 ms 5920 KB Output is correct
31 Correct 278 ms 5832 KB Output is correct
32 Correct 279 ms 5992 KB Output is correct
33 Correct 276 ms 5880 KB Output is correct
34 Correct 295 ms 5976 KB Output is correct
35 Correct 278 ms 5924 KB Output is correct
36 Correct 280 ms 5844 KB Output is correct
37 Correct 276 ms 5872 KB Output is correct
38 Correct 289 ms 6016 KB Output is correct
39 Correct 278 ms 6036 KB Output is correct
40 Correct 285 ms 6020 KB Output is correct
41 Correct 279 ms 5916 KB Output is correct
42 Correct 279 ms 5920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 315 ms 6728 KB Output is correct
2 Correct 301 ms 6760 KB Output is correct
3 Correct 300 ms 6724 KB Output is correct
4 Correct 292 ms 6716 KB Output is correct
5 Correct 298 ms 6856 KB Output is correct
6 Correct 288 ms 6640 KB Output is correct
7 Correct 289 ms 6724 KB Output is correct
8 Correct 287 ms 6804 KB Output is correct
9 Correct 292 ms 6700 KB Output is correct
10 Correct 303 ms 6764 KB Output is correct
11 Correct 292 ms 6756 KB Output is correct
12 Correct 297 ms 6984 KB Output is correct
13 Correct 285 ms 6728 KB Output is correct
14 Correct 289 ms 6744 KB Output is correct
15 Correct 297 ms 6876 KB Output is correct
16 Correct 293 ms 6772 KB Output is correct
17 Correct 297 ms 6924 KB Output is correct
18 Correct 299 ms 6732 KB Output is correct
19 Correct 292 ms 6784 KB Output is correct
20 Correct 300 ms 6808 KB Output is correct
21 Correct 286 ms 6732 KB Output is correct
22 Correct 299 ms 6020 KB Output is correct
23 Correct 271 ms 5996 KB Output is correct
24 Correct 278 ms 5996 KB Output is correct
25 Correct 273 ms 5868 KB Output is correct
26 Correct 275 ms 5880 KB Output is correct
27 Correct 281 ms 6088 KB Output is correct
28 Correct 278 ms 5900 KB Output is correct
29 Correct 278 ms 5980 KB Output is correct
30 Correct 278 ms 5920 KB Output is correct
31 Correct 278 ms 5832 KB Output is correct
32 Correct 279 ms 5992 KB Output is correct
33 Correct 276 ms 5880 KB Output is correct
34 Correct 295 ms 5976 KB Output is correct
35 Correct 278 ms 5924 KB Output is correct
36 Correct 280 ms 5844 KB Output is correct
37 Correct 276 ms 5872 KB Output is correct
38 Correct 289 ms 6016 KB Output is correct
39 Correct 278 ms 6036 KB Output is correct
40 Correct 285 ms 6020 KB Output is correct
41 Correct 279 ms 5916 KB Output is correct
42 Correct 279 ms 5920 KB Output is correct
43 Incorrect 272 ms 5864 KB Output isn't correct
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 315 ms 6728 KB Output is correct
2 Correct 301 ms 6760 KB Output is correct
3 Correct 300 ms 6724 KB Output is correct
4 Correct 292 ms 6716 KB Output is correct
5 Correct 298 ms 6856 KB Output is correct
6 Correct 288 ms 6640 KB Output is correct
7 Correct 289 ms 6724 KB Output is correct
8 Correct 287 ms 6804 KB Output is correct
9 Correct 292 ms 6700 KB Output is correct
10 Correct 303 ms 6764 KB Output is correct
11 Correct 292 ms 6756 KB Output is correct
12 Correct 297 ms 6984 KB Output is correct
13 Correct 285 ms 6728 KB Output is correct
14 Correct 289 ms 6744 KB Output is correct
15 Correct 297 ms 6876 KB Output is correct
16 Correct 293 ms 6772 KB Output is correct
17 Correct 297 ms 6924 KB Output is correct
18 Correct 299 ms 6732 KB Output is correct
19 Correct 292 ms 6784 KB Output is correct
20 Correct 300 ms 6808 KB Output is correct
21 Correct 286 ms 6732 KB Output is correct
22 Correct 299 ms 6020 KB Output is correct
23 Correct 271 ms 5996 KB Output is correct
24 Correct 278 ms 5996 KB Output is correct
25 Correct 273 ms 5868 KB Output is correct
26 Correct 275 ms 5880 KB Output is correct
27 Correct 281 ms 6088 KB Output is correct
28 Correct 278 ms 5900 KB Output is correct
29 Correct 278 ms 5980 KB Output is correct
30 Correct 278 ms 5920 KB Output is correct
31 Correct 278 ms 5832 KB Output is correct
32 Correct 279 ms 5992 KB Output is correct
33 Correct 276 ms 5880 KB Output is correct
34 Correct 295 ms 5976 KB Output is correct
35 Correct 278 ms 5924 KB Output is correct
36 Correct 280 ms 5844 KB Output is correct
37 Correct 276 ms 5872 KB Output is correct
38 Correct 289 ms 6016 KB Output is correct
39 Correct 278 ms 6036 KB Output is correct
40 Correct 285 ms 6020 KB Output is correct
41 Correct 279 ms 5916 KB Output is correct
42 Correct 279 ms 5920 KB Output is correct
43 Incorrect 272 ms 5864 KB Output isn't correct
44 Halted 0 ms 0 KB -