Submission #232477

# Submission time Handle Problem Language Result Execution time Memory
232477 2020-05-17T07:19:44 Z kartel Ispit (COCI19_ispit) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +2005
//#define N1 +1001000
#define M ll(998244353)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;

int i, j, k, n, hp[N][N], hs[N][N], p[N], can, hsh;
string s[N];
map <int, int> mp;

int sum(int x, int y) {return (x + y) % M;}
int mult(int x, int y) {return (x * 1ll * y) % M;}

int main()
{
    srand(time(0));
    ios_base::sync_with_stdio(0);
    iostream::sync_with_stdio(0);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

//    in("input.txt");
//    out("output.txt");

//    getline(cin, st);
    cin >> n >> k;

    p[0] = 1;
    for (i = 1; i <= n; i++) p[i] = mult(p[i - 1], 31);

    for (i = 1; i <= n; i++)
    {
        cin >> s[i];
        s[i] = " " + s[i];
        hp[i][0] = 0;
        for (j = 1; j <= n; j++)
            hp[i][j] = sum(hp[i][j - 1], mult(s[i][j] - 'a' + 1, p[j - 1]));

        hs[i][n + 1] = 0;

        for (j = n; j >= 1; j--)
            hs[i][j] = sum(mult(hs[i][j + 1], 31), s[i][j] - 'a' + 1);
    }

    for (j = 1; j <= n - k + 1; j++)
    {
        bool found = 0;

        mp.clear();

        for (i = 1; i <= n; i++)
        {
            hsh = hp[i][j - 1];
            hsh = sum(hsh, mult(hs[i][j + k], p[j - 1]));

            mp[hsh]++;

            if (mp[hsh] >= 2)
                found = 1;
        }

        if (!found) continue;

        mp.clear();

        for (i = 1; i <= n; i++)
          {
                string ns = "";
                for (int nj = j; nj <= j + k - 1; nj++)
                    ns += s[i][nj];

                sort(ns.begin(), ns.end());

                hsh = 0;

                for (nj = 0; nj < k; nj++)
                    hsh = sum(hsh, mult(ns[тj] - 'a' + 1, p[тj]));

                mp[hsh]++;
                if (mp[hsh] > 1) can = 1;
          }


    }

    cout << (can ? "DA" : "NE");

}


//3 - 4
//4 - 5
//y < z + x < y + 2 * x

Compilation message

ispit.cpp:96:44: error: stray '\321' in program
                     hsh = sum(hsh, mult(ns[тj] - 'a' + 1, p[тj]));
                                            ^
ispit.cpp:96:45: error: stray '\202' in program
                     hsh = sum(hsh, mult(ns[тj] - 'a' + 1, p[тj]));
                                             ^
ispit.cpp:96:62: error: stray '\321' in program
                     hsh = sum(hsh, mult(ns[тj] - 'a' + 1, p[тj]));
                                                              ^
ispit.cpp:96:63: error: stray '\202' in program
                     hsh = sum(hsh, mult(ns[тj] - 'a' + 1, p[тj]));
                                                               ^
ispit.cpp: In function 'int main()':
ispit.cpp:95:22: error: 'nj' was not declared in this scope
                 for (nj = 0; nj < k; nj++)
                      ^~
ispit.cpp:95:22: note: suggested alternative: 'ns'
                 for (nj = 0; nj < k; nj++)
                      ^~
                      ns