Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream f("expandmat.in");
- ofstream g("expandmat.out");
- int n,q,cnt[3][3][30];
- int64_t p[64];
- int main()
- {
- f>>n>>q;
- p[0]=1;
- for(int i=1; i<=n; i++)p[i]=p[i-1]*2;
- for(; q; q--)
- {
- int64_t L,C;
- char c;
- int v;
- f>>L>>C>>c;
- v=c-'a';
- for(int i=n; i>=2; i--)
- {
- if(L>p[i-1]&&C>p[i-1])
- {
- L=p[i]+1-L;
- C=p[i]+1-C;
- }
- else if(L>p[i-1])
- {
- L=L-p[i-1];
- v=v+4;
- }
- else if(C>p[i-1])
- {
- C=C-p[i-1];
- v=v+23;
- }
- }
- v%=26;
- cnt[L][C][v]++;
- }
- int sol=0;
- for(int i=1; i<=2; i++)
- for(int j=1; j<=2; j++)
- {
- int mx=cnt[i][j][0];
- for(int k=1; k<26; k++)
- mx=max(mx,cnt[i][j][k]);
- sol+=mx;
- }
- g<<sol;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment