QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#716201#8334. GenexinlengweishangCompile Error//C++203.3kb2024-11-06 14:39:272024-11-06 14:39:32

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 14:39:32]
  • 评测
  • [2024-11-06 14:39:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e9 + 5;
const long long M1 = 998244353ll, M2 = 19260817ll, d1 = 233ll, d2 = 2333ll;

ll f1[309][60009], f2[309][60009], t1[60009], t2[60009], di1[60009], di2[60009];
string st[309], s;
ll flag, chunk[25], ck, n, m, q;
ll temp;
void gan(int l, int r, int k, int c)
{
	
//    cout<<k<<" "<<l<<" "<<r<<" "<<c<<" "<<chunk[c]<<" \n";
    if(chunk[c]>ck){
    	flaf=20;
    	return ;
	}
	if (r - l + 1 <= 1)
    {
        // cout<<"&"<<l<<"---"<<r<<endl;
        for (int i = l; i <= r; i++)
            if (st[k][i-1] != s[i-1]){
                flag++;
                // cout<<"&"<<i<<endl;
            }
                
        return;
    }
    if (flag > ck)
        return;

    ll s1 = (f1[k][r] - f1[k][l - 1]+M1)%M1;
    ll s2 = (f2[k][r] - f2[k][l - 1]+M2)%M2;
    ll s3 = (t1[r] - t1[l - 1]+M1)%M1;
    ll s4 = (t2[r] - t2[l - 1]+M2)%M2;
    if (s1 == s3 && s2 == s4)
        return;
        

    int mid = (l + r) >> 1;
    s1 = (f1[k][mid] - f1[k][l - 1]+M1)%M1;
    s2 = (f2[k][mid] - f2[k][l - 1]+M2)%M2;
    s3 = (t1[mid] - t1[l - 1]+M1)%M1;
    s4 = (t2[mid] - t2[l - 1]+M2)%M2;
    // cout<<"#"<<l<<"--"<<mid<<":"<<s1<<" "<<s3<<" "<<s2<<" "<<s4<<endl;
    if (s1 != s3 || s2 != s4)
    {
        chunk[c + 1]++;
        gan(l, mid, k, c + 1);
    }
    
    if (flag > ck)
        return;
        
    s1 = (f1[k][r] - f1[k][mid]+M1)%M1;
    s2 = (f2[k][r] - f2[k][mid]+M2)%M2;
    s3 = (t1[r] - t1[mid]+M1)%M1;
    s4 = (t2[r] - t2[mid]+M2)%M2;
    //  cout<<"#"<<mid+1<<"--"<<r<<":"<<s1<<" "<<s3<<" "<<s2<<" "<<s4<<endl;
    if (s1 != s3 || s2 != s4)
    {
        chunk[c + 1]++;
        gan(mid + 1, r, k, c + 1);
    }
}

int main()
{
    scanf("%lld%lld%lld%lld", &n, &q, &m, &ck);
    char ch = getchar();
    di1[0] = 1;
    di2[0] = 1;
    for (int i = 1; i <= m; i++)
    {
        di1[i] = di1[i - 1] * d1;
        di1[i] %= M1;
        di2[i] = di2[i - 1] * d2;
        di2[i] %= M2;
    }
    for (int i = 1; i <= n; i++)
    {
        getline(cin, st[i]);
        f1[i][0]=0;
        f2[i][0]=0;
        for (int j = 1; j <= m; j++)
        {
            f1[i][j] = f1[i][j - 1]* d1 + st[i][j-1] ;
            f1[i][j] %= M1;
            f2[i][j] = f2[i][j - 1]* d2 + st[i][j-1] ;
            f2[i][j] %= M2;
            // cout<<f1[i][j]<<" ";
        }
        // cout<<endl;
    }
    while (q--)
    {
        // cout<<"\n!"<<q<<endl;
        getline(cin, s);
        int ans = 0;
        t1[0] = 0;
        t2[0] = 0;
        for (int j = 1; j <= m; j++)
        {
            t1[j] = t1[j - 1]* di1[j-1] + s[j-1] ;
            t1[j] %= M1;
            t2[j] = t2[j - 1]* di2[j-1] + s[j-1] ;
            t2[j] %= M2;
        }
        for (int i = 1; i <= n; i++)
        {
            flag = 0;
            temp=0;
            for(int i=1;i<20;i++) chunk[i]=0;
            gan(1, m, i, 1);
            if (flag <= ck)
                ans++;
//            if(m==15){
//            	printf("q=%d i=%d ",q,i);
//                for(int q=1;q<=15;q++) printf("%d ",chunk[q]);
//            	printf(" | ");
//			}
        }
//        if(m!=15)
        printf("%lld\n", ans);
    }
    return 0;
}
/*
6 4 4 1
kaki
kika 
manu
nana
tepu
tero
kaka
mana
teri
anan
*/

详细

answer.code: In function ‘void gan(int, int, int, int)’:
answer.code:16:9: error: ‘flaf’ was not declared in this scope; did you mean ‘fmaf’?
   16 |         flaf=20;
      |         ^~~~
      |         fmaf
answer.code: In function ‘int main()’:
answer.code:125:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat=]
  125 |         printf("%lld\n", ans);
      |                 ~~~^     ~~~
      |                    |     |
      |                    |     int
      |                    long long int
      |                 %d
answer.code:70:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   70 |     scanf("%lld%lld%lld%lld", &n, &q, &m, &ck);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~