yangchang's blog

By yangchang, history, 3 months ago, In English

I solved this problem using a method similar to ‘search pruning’. I found that the expected complexity of this method is guaranteed by running the code.

How can I prove it mathematically rigorous?

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+10;

struct{int s[2];}t[maxn * 64];
int tot;
void ins(unsigned long long x){for(int i=64,u=0;~--i;u=t[u].s[x>>i&1]?:t[u].s[x>>i&1]=++tot);}
void dfs(int u,int v,int _d){
	if(!_d)cout<<"YES",exit(0);
	for(int c:{0,1})for(int d:{0,1})
		if(!(c&d))if(t[u].s[c]&&t[v].s[d])
			dfs(t[u].s[c],t[v].s[d],_d-1);
}

int main() {
	mt19937_64 rng(random_device{}());
	int n;cin>>n;
	for(int i=1;i<=n;++i)ins(rng());
	dfs(0,0,64);cout<<"NO";
}

Full text and comments »

  • Vote: I like it
  • +7
  • Vote: I do not like it

By yangchang, history, 5 months ago, In English

c++17 on Linux AC

c++20 on Windows RE

As you can see, C++20 on Windows got RE. The only reason is C++20's unconfigured infinite recursion stack.

Full text and comments »

  • Vote: I like it
  • +9
  • Vote: I do not like it

By yangchang, history, 10 months ago, In English

When I try to compile such a programme:

	#error //there is a tab before "#error"

G++ will report an error:

a.cpp:1:10: error: #error
    1 | #error
      | ^~~~~

However, I'm using tab indentation, which I think is G++ converting tabs to 8 spaces!

that is my G++ version:

g++ (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r4) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I tried previous versions of G++, at least on 10.*. * version, it is positioned correctly.

I need G++ to position it correctly, how do I fix it?

Please don't suggest I use space indentation

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it