답안 #223204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223204 2020-04-15T05:07:26 Z tqbfjotld Trener (COCI20_trener) C++14
110 / 110
261 ms 16068 KB
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
unordered_map<string,int> ways;

int main(){
    int n,k;
    cin>>n;
    cin>>k;
    for (int x = 0; x<n; x++){
        for (int y = 0; y<k; y++){
            string str;
            cin>>str;
            if (str.size()==1){
                ways[str]++;
            }
            else{
                string str1 = "";
                string str2 = "";
                for (int i = 0; i<str.size(); i++){
                    if (i!=0){
                        str2 += str[i];
                    }
                    if (i!=str.size()-1){
                        str1+=str[i];
                    }
                }
                if (str1!=str2){
                    ways[str] += ways[str1];
                    ways[str] %= MOD;
                    ways[str] += ways[str2];
                    ways[str] %= MOD;
                }
                else{
                    ways[str] += ways[str1];
                    ways[str] %=MOD;
                }
            }
        }
    }
    int ans = 0;
    for (auto x : ways){
        if (x.first.size()==n){
            ans += x.second;
            ans %= MOD;
        }
    }
    printf("%d",ans);
}

Compilation message

trener.cpp: In function 'int main()':
trener.cpp:20:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int i = 0; i<str.size(); i++){
                                 ~^~~~~~~~~~~
trener.cpp:24:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     if (i!=str.size()-1){
                         ~^~~~~~~~~~~~~~
trener.cpp:43:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (x.first.size()==n){
             ~~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1400 KB Output is correct
2 Correct 18 ms 1328 KB Output is correct
3 Correct 18 ms 1280 KB Output is correct
4 Correct 15 ms 256 KB Output is correct
5 Correct 18 ms 1152 KB Output is correct
6 Correct 18 ms 1280 KB Output is correct
7 Correct 14 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 22 ms 1400 KB Output is correct
6 Correct 18 ms 1328 KB Output is correct
7 Correct 18 ms 1280 KB Output is correct
8 Correct 15 ms 256 KB Output is correct
9 Correct 18 ms 1152 KB Output is correct
10 Correct 18 ms 1280 KB Output is correct
11 Correct 14 ms 384 KB Output is correct
12 Correct 256 ms 16056 KB Output is correct
13 Correct 248 ms 16068 KB Output is correct
14 Correct 249 ms 16056 KB Output is correct
15 Correct 261 ms 16056 KB Output is correct
16 Correct 153 ms 512 KB Output is correct
17 Correct 214 ms 10632 KB Output is correct
18 Correct 223 ms 12536 KB Output is correct
19 Correct 212 ms 12420 KB Output is correct
20 Correct 210 ms 12424 KB Output is correct
21 Correct 228 ms 12680 KB Output is correct
22 Correct 154 ms 2296 KB Output is correct