QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#796399#8313. Nim Cheatereggegg185Compile Error//C++141.2kb2024-12-01 18:09:292024-12-01 18:09:30

Judging History

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

  • [2024-12-01 18:09:30]
  • 评测
  • [2024-12-01 18:09:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> vec[40010]; int a[40010],b[40010],req[40010],ans[40010],siz[40010],son[40010],sum,fa[40005];
void D(int now) {
	siz[now] = 1; for(auto v:vec[now]) {
		D(v); siz[now] += siz[v];
		if(!son[now] || siz[son[now]]<siz[v]) son[now] = v;
	}
}
long long dp[20][17005],tmp[17005]; //sigh
void dfs(int now,int dep) {
	sum ^= a[now]; ans[now] = dp[dep][sum];
	for(auto v:vec[now]) {
		if(v == son[now]) continue;
		for(int i = 0; i < 16384; i++) dp[dep+1][i] = min(dp[dep][i],dp[dep][i^a[v]]+b[v]);
		dfs(v,dep+1);
	} if(son[now]) {
		for(int i = 0; i < 16384; i++) tmp[i] = dp[dep][i];
		for(int i = 0; i < 16384; i++) dp[dep][i] = min(tmp[i],tmp[i^a[son[now]]]+b[son[now]]);
		dfs(son[now],dep);
	} sum ^= a[now];
}
char s[10];
int main() {
	int n,cnt = 0,cur = 0; scanf("%d",&n); for(int i = 1; i <= n; i++) {
		scanf("%s",s+1);
		if(s[1] == 'A') {cnt++; scanf("%d%d",&a[cnt],&b[cnt]); vec[fa[cnt] = cur].push_back(cnt); cur = cnt;}
		else cur = fa[cur]; req[i] = cur;
	} memset(dp,0x3f,sizeof(dp)); dp[0][0] = 0; dfs(0,0); for(int i = 1; i <= n; i++) printf("%d\n",ans[req[i]]);
	return 0;
}

Details

cc1plus: error: ‘::main’ must return ‘int’
answer.code: In function ‘int main()’:
answer.code:26:40: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
   26 |         int n,cnt = 0,cur = 0; scanf("%d",&n); for(int i = 1; i <= n; i++) {
      |                                       ~^  ~~
      |                                        |  |
      |                                        |  long long int*
      |                                        int*
      |                                       %lld
answer.code:28:49: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
   28 |                 if(s[1] == 'A') {cnt++; scanf("%d%d",&a[cnt],&b[cnt]); vec[fa[cnt] = cur].push_back(cnt); cur = cnt;}
      |                                                ~^    ~~~~~~~
      |                                                 |    |
      |                                                 int* long long int*
      |                                                %lld
answer.code:28:51: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=]
   28 |                 if(s[1] == 'A') {cnt++; scanf("%d%d",&a[cnt],&b[cnt]); vec[fa[cnt] = cur].push_back(cnt); cur = cnt;}
      |                                                  ~^          ~~~~~~~
      |                                                   |          |
      |                                                   int*       long long int*
      |                                                  %lld
answer.code:30:100: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   30 |         } memset(dp,0x3f,sizeof(dp)); dp[0][0] = 0; dfs(0,0); for(int i = 1; i <= n; i++) printf("%d\n",ans[req[i]]);
      |                                                                                                   ~^    ~~~~~~~~~~~
      |                                                                                                    |              |
      |                                                                                                    int            long long int
      |                                                                                                   %lld
answer.code:26:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |         int n,cnt = 0,cur = 0; scanf("%d",&n); for(int i = 1; i <= n; i++) {
      |                                ~~~~~^~~~~~~~~
answer.code:27:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |                 scanf("%s",s+1);
      |                 ~~~~~^~~~~~~~~~
answer.code:28:46: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |                 if(s[1] == 'A') {cnt++; scanf("%d%d",&a[cnt],&b[cnt]); vec[fa[cnt] = cur].push_back(cnt); cur = cnt;}
      |                                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~