답안 #223211

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223211 2020-04-15T05:21:35 Z errorgorn Trener (COCI20_trener) C++14
22 / 110
22 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

int n,k;

map<string,ll> m[2];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	cin>>n>>k;
	
	m[0][""]=1;
	
	int a=0,b=1;
	for (int x=0;x<n;x++){
		for (int y=0;y<k;y++){
			string s,t;
			ll res=0;
			cin>>s;
			t=s;
			t.pop_back();
			if (m[a].count(t)) res+=m[a][t];
			for (int x=1;x<s.size();x++){
				if (t[x-1]!=s[x]){
					t[x-1]=s[x];
					if (m[a].count(t)) res+=m[a][t];
				}
			}
			m[b][s]+=res;
			//cout<<s<<" "<<res<<endl;
		}
		swap(a,b);
		m[b].clear();
	}
	
	ll ans=0;
	for (auto &it:m[a]){
		ans+=it.second;
	}
	
	cout<<ans<<endl;
}

Compilation message

trener.cpp: In function 'int main()':
trener.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int x=1;x<s.size();x++){
                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Incorrect 22 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -