Submission #845469

#TimeUsernameProblemLanguageResultExecution timeMemory
845469vjudge1Trener (COCI20_trener)C++17
0 / 110
18 ms856 KiB
#include <bits/stdc++.h> #pragma optimize "DostSeferoğlu" #pragma GCC optimize("unroll-loops,Ofast") #pragma GCC target("avx2,tune=native") using namespace std; #define int long long #define pii pair<int,int> #define bg begin #define vi vector<int> #define endl '\n' #define vvi vector<vi> #define pc __builtin_popcountll #define vp vector<pii> #define sp << " " << #define all(x) x.bg()+1,x.end() #define ff first #define ss second #define brake {cout << "OK\n";return;} #define debug(x) {cout << #x << ": "; for (auto it : x) cout << it << " ";cout << endl;} #define FF(xxx,sss,yyy) for (int xxx=sss;xxx<=yyy;++xxx) #define F(xx,yy) for (int xx=1;xx<=yy;++xx) #define pb push_back const int inf = 1e18; const int MOD = 1e9+7; const int N = 2e5+1; std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> distrib(10000,1000000007); const int A = distrib(gen); const int B = distrib(gen); const int C = distrib(gen); int add(int x,int y) { return ((x%MOD)+(y%MOD))%MOD; } int mult(int x,int y) { return ((x%MOD)*(y%MOD))%MOD; } int hsha(string& s,int l,int r) { int ret; for (int k=l;k<=r;k++) { ret = add(mult(ret,A),s[k-1]); } return ret; } int hshb(string& s,int l,int r) { int ret; for (int k=l;k<=r;k++) { ret = add(mult(ret,B),s[k-1]); } return ret; } int hshc(string& s,int l,int r) { int ret; for (int k=l;k<=r;k++) { ret = add(mult(ret,C),s[k-1]); } return ret; } void solve() { int n,k; cin >> n >> k; int fhasha[n+1][k+1],phasha[n+1][k+1],shasha[n+1][k+1]; int fhashb[n+1][k+1],phashb[n+1][k+1],shashb[n+1][k+1]; int fhashc[n+1][k+1],phashc[n+1][k+1],shashc[n+1][k+1]; F(i,n) { F(j,k) { string s; cin >> s; fhasha[i][j] = hsha(s,1,i); fhashb[i][j] = hshb(s,1,i); fhashc[i][j] = hshc(s,1,i); if (i > 1) { shasha[i][j] = hsha(s,2,i); shashb[i][j] = hshb(s,2,i); shashc[i][j] = hshc(s,2,i); phasha[i][j] = hsha(s,1,i-1); phashb[i][j] = hshb(s,1,i-1); phashc[i][j] = hshc(s,1,i-1); } } } int ans[n+1][k+1]; memset(ans,0,sizeof ans); F(i,k) ans[1][i] = 1; for (int i=1;i<n;i++) { for (int j=1;j<=k;j++) { for (int j2=1;j2<=k;j2++) { if (phasha[i+1][j2] == fhasha[i][j] || shasha[i+1][j2] == fhasha[i][j]) { if (phashb[i+1][j2] == fhashb[i][j] || shashb[i+1][j2] == fhashb[i][j]) { if (phashc[i+1][j2] == fhashc[i][j] || shashc[i+1][j2] == fhashc[i][j]) { ans[i+1][j2]+=ans[i][j]; } } } } } } int sm = 0; F(i,k) { sm = add(sm,ans[n][i]); } cout << sm << endl; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); #ifdef Local freopen("input.in", "r", stdin); freopen("input.out", "w", stdout); #endif int t = 1; //cin >> t; while (t --> 0) solve(); }

Compilation message (stderr)

trener.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    2 | #pragma optimize "DostSeferoğlu"
      | 
trener.cpp: In function 'long long int hsha(std::string&, long long int, long long int)':
trener.cpp:43:12: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |     return ret;
      |            ^~~
trener.cpp: In function 'long long int hshb(std::string&, long long int, long long int)':
trener.cpp:50:12: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |     return ret;
      |            ^~~
trener.cpp: In function 'long long int hshc(std::string&, long long int, long long int)':
trener.cpp:57:12: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   57 |     return ret;
      |            ^~~
trener.cpp: In function 'void solve()':
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:53:9: note: 'ret' was declared here
   53 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:46:9: note: 'ret' was declared here
   46 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:39:9: note: 'ret' was declared here
   39 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:53:9: note: 'ret' was declared here
   53 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:46:9: note: 'ret' was declared here
   46 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:39:9: note: 'ret' was declared here
   39 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:53:9: note: 'ret' was declared here
   53 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:46:9: note: 'ret' was declared here
   46 |     int ret;
      |         ^~~
trener.cpp:36:15: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |     return ((x%MOD)*(y%MOD))%MOD;
      |             ~~^~~~~
trener.cpp:39:9: note: 'ret' was declared here
   39 |     int ret;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...