QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627939#9356. LRU Algorithmguodong#Compile Error//C++171.8kb2024-10-10 17:44:142024-10-10 17:44:15

Judging History

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

  • [2024-10-10 17:44:15]
  • 评测
  • [2024-10-10 17:44:14]
  • 提交

answer

#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define int long long 
using namespace std;
#define For(i,a,b) for(int i = a; i <= b; ++i)
#define push_back emplace_back
#define mp make_pair
inline int read(){
	int x=0;
	bool f=false;
	char ch=getchar();
	while(!isdigit(ch))f=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return f?-x:x;
}
int T = 0;
const int mod = 1e17 + 3;
const int base = 13;
int mul(int x,int y){
	int t = x * y - (1.L) * (x * y / mod) * mod;
	t %= mod;
	if(t < 0) return t + mod;
	return t;
}
void Mod(int &x){
	return x % mod;
}
int Base[5050];
signed main(){
#ifdef NICEGUODONG
	freopen("data.in","r",stdin);
#endif
	int T;
	T =read();
	Base[0] = 1;
	For(i,1,5050 - 10){
		Base[i] = mul(Base[i-1],base);
	}
	while(T--){
		int n,q;
		n = read() ,q = read();
		vector<int> a;
#define M asdfa
		vector<vector<int>> h(n + 2);
		For(i,1,n){
			int x;
			x = read();
			++x;
			a.push_back(x);
			int hashsum = 0,cur = 1,cnt = 0;
			vector<int> vis(n + 1);
			for(int j = a.size() - 1; j >= 0; --j){
				if(vis[a[j]]) continue;
				++cnt;
				vis[a[j]] = 1;	
				hashsum += mul(Base[cnt - 1],a[j]);
				Mod(hashsum);
				h[cnt].push_back(hashsum);
				cur = mul(cur,base);
			}
			while(cnt < n){
				++cnt;
				hashsum += Base[cnt - 1];
				Mod(hashsum);
				h[cnt].push_back(hashsum);
			}
		}
		for(int i = 1; i <= q; ++i){
			int r;
			r = read();
			int hashsum = 0;
			for(int i = 1; i <= r; ++i){
				int x;
				x = read();
				++x;
				hashsum += mul(Base[i - 1] , x);
				Mod(hashsum);
			}
			int flag = 0;
			for(auto &x : h[r]){
				if(x == hashsum){
					flag = 1;
					break;
				}
			}
			if(flag){
				puts("Yes");
			}
			else 
				puts("No");
		}
	}

}


Details

answer.code: In function ‘void Mod(long long int&)’:
answer.code:26:18: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
   26 |         return x % mod;
      |                ~~^~~~~