답안 #79938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
79938 2018-10-17T12:43:54 Z luckyboy Lozinke (COCI17_lozinke) C++14
45 / 100
651 ms 66560 KB
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 20005
#define maxm 500005
#define pii pair <int,int>
#define Task "Lozinke"
using namespace std;
int n;
string s[maxn];
map <string,int> dd,dd1;
map <string,bool> ok[maxn],ok1[maxn];
long long ans;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Task".inp", "r",stdin);
    //freopen(Task".out", "w",stdout);
    cin >> n;
    FOR(i,1,n)
    {
        cin >> s[i];
        int temp = s[i].size();
        FOR(j,1,temp)
            FOR(pos,0,temp - j)
            {
                string ww = s[i].substr(pos,j);
                if (ok[i][ww]) continue;
                ok[i][ww] = 1;
                ans += dd[ww];
            }
        ++dd[s[i]];
    }
    FORD(i,n,1)
    {
        int temp = s[i].size();
        FOR(j,1,temp)
            FOR(pos,0,temp - j)
            {
                string ww = s[i].substr(pos,j);
                if (ok1[i][ww]) continue;
                ok1[i][ww] = 1;
                ans += dd1[ww];
            }
        ++dd1[s[i]];
//        FOR(j,1,temp)
//            FOR(pos,0,temp - j)
//            {
//                string ww = s[i].substr(pos,j);
//                ok1[i][ww] = 0;
//            }
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2936 KB Output is correct
2 Correct 4 ms 3028 KB Output is correct
3 Correct 6 ms 3232 KB Output is correct
4 Correct 8 ms 3528 KB Output is correct
5 Correct 32 ms 6776 KB Output is correct
6 Correct 52 ms 9360 KB Output is correct
7 Correct 68 ms 11524 KB Output is correct
8 Correct 120 ms 16772 KB Output is correct
9 Correct 305 ms 35828 KB Output is correct
10 Runtime error 628 ms 66348 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
11 Runtime error 487 ms 66348 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
12 Runtime error 628 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 588 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 651 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 634 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 517 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 182 ms 66560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
18 Runtime error 128 ms 66560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
19 Runtime error 618 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 447 ms 66560 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.