QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#479382#5438. Half MixedUESTC_DECAYALI#Compile Error//C++171.0kb2024-07-15 16:59:422024-07-15 16:59:42

Judging History

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

  • [2024-07-15 16:59:42]
  • 评测
  • [2024-07-15 16:59:42]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
#define int long long
#define RI register int
#define CI const int&
using namespace std;
const int N=1e6+5;
int t,n,m,p[N],ans[N];
signed main()
{
	RI i,j; for (i=1;i<=1000000;++i) p[i]=i*(i+1)/2LL;
	for (scanf("%lld",&t);t;--t)
	{
		scanf("%lld%lld",&n,&m);
		if ((n*(n+1)/2LL)%2==1&&(m*(m+1)/2LL)%2==1) { puts("No"); continue; }
		bool swaped=0; if ((n*(n+1)/2LL)%2==1) swap(n,m),swaped=1;
		vector <int> vec; int tar=n*(n+1)/4LL,sum=0;
		while (tar>0)
		{
			int pos=upper_bound(p+1,p+1000000,tar)-p-1;
			while (sum+pos+tar-p[pos]<n) --pos;
			vec.push_back(pos); sum+=pos; tar-=p[pos];
		}
		//for (auto x:vec) printf("%lld ",x); putchar('\n');
		int c=0; i=0; puts("Yes");
		for (auto x:vec)
		{
			for (j=1;j<=x;++j) ans[++i]=c;
			c^=1;
		}
		if (swaped)
		{
			for (i=1;i<=m;++i)
			for (j=1;j<=n;++j) printf("%lld%c",ans[j]," \n"[j==n]);
		} else
		{
			for (i=1;i<=n;++i)
			for (j=1;j<=m;++j) printf("%lld%c",ans[i]," \n"[j==m]);
		}
	}
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:12:12: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 |         RI i,j; for (i=1;i<=1000000;++i) p[i]=i*(i+1)/2LL;
      |            ^
answer.code:12:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   12 |         RI i,j; for (i=1;i<=1000000;++i) p[i]=i*(i+1)/2LL;
      |              ^
answer.code:18:17: error: ‘vector’ was not declared in this scope
   18 |                 vector <int> vec; int tar=n*(n+1)/4LL,sum=0;
      |                 ^~~~~~
answer.code:4:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    3 | #include<algorithm>
  +++ |+#include <vector>
    4 | #define int long long
answer.code:4:13: error: expected primary-expression before ‘long’
    4 | #define int long long
      |             ^~~~
answer.code:18:25: note: in expansion of macro ‘int’
   18 |                 vector <int> vec; int tar=n*(n+1)/4LL,sum=0;
      |                         ^~~
answer.code:23:25: error: ‘vec’ was not declared in this scope
   23 |                         vec.push_back(pos); sum+=pos; tar-=p[pos];
      |                         ^~~
answer.code:27:29: error: ‘vec’ was not declared in this scope
   27 |                 for (auto x:vec)
      |                             ^~~
answer.code:13:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         for (scanf("%lld",&t);t;--t)
      |              ~~~~~^~~~~~~~~~~
answer.code:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%lld%lld",&n,&m);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~