QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#473990#5090. 妙妙题FffooooCompile Error//C++142.6kb2024-07-12 15:24:052024-07-12 15:24:05

Judging History

This is the latest submission verdict.

  • [2024-07-12 15:24:05]
  • Judged
  • [2024-07-12 15:24:05]
  • Submitted

answer

#include<bits/stdc++.h>
#include "tmp.h"
using namespace std;
/*
有 $n$ 个人,每个人可以看到其他所有人帽子的颜色 
构造一种策略,表示当一个人看到其他人的帽子颜色是 $S$ 是做出的猜测是自己的帽子是黑/白 
使得至少有 $\lfloor \dfrac{n-1}{2} \rfloor$ 个人猜中 
$n\le 64$ 
函数性交互题 

如果可以知道最终 $1$ 的个数是奇数还是偶数,那么每个人都可以猜出正确的答案 
如果能找到一条划分,那么将左部的人认为总数是奇数,右部认为是偶数,那就可以达到一半的正确性 
但是因为没有编号,所以只能通过看到的来判断这条线 
那么在单位圆上,将这 $n$ 个点作为单位圆的 $n$ 等分点 
将黑点对应的向量和算出,那么也得到了一条线 
按照这一条线去算,首先白点不会有影响 
那么对于黑点,相当于少了他自己的这一条向量。那么无论如何,他在向量的哪一侧是不会改变的(因为多的向量指向自己,不可能让整个向量直接超过180) 
考虑特殊情况 
如果发现与向量共线,那么就直接猜测是黑点 
如果发现是零向量,那么直接猜是白点 
首先这样可以过掉黑白交替的情况 
然后对于普通情况,如果贡献的两个点都是白点,那么只会损失 $2$ 的正确率,还是可以满足条件 
如果发现零向量的是黑点,那么就只能说明这一条向量原本就是指向他的,因此只有他会错 
*/
const int NN = 64;
const double eps = 1e-8;
const double pi = acos(-1);
int n;

int sgn( const double x ) { return ( x > eps ) ? 1 : ( x < -eps ? -1 : 0 ); }
struct Point {
	double x, y;
	friend Point operator + (const Point a, const Point b) { return (Point) { a.x + b.x, a.y + b.y }; }
	friend Point operator - (const Point a, const Point b) { return (Point) { a.x - b.x, a.y - b.y }; }
	friend bool operator % (const Point a, const Point b) { return a.x * b.y - a.y * b.x ; }
}p[NN];
void init(int N, bool Type, int p) {
	n = N;
	const double alpha = 2.0 * pi / (double)n;
	for(int i = 0; i < n; ++i) p[i].x = cos( alpha * i ), p[i].y = sin( alpha * i );
}
int a[NN];
bool guess( unsigned long long A, int x ) {
	Point xf = (Point){0, 0};
	bool sum = false;
	for(int i = 0; i < n; ++i) a[i] = ( A & ( 1ll << i ) ? 1 : 0 );
	for(int i = 0; i < n; ++i) if( a[i] ) xf = xf + p[i], sum ^= 1;
	if( !sgn( xf.x ) and !sgn( xf.y ) ) return false;
	const int xm =  sgn( xf % p[n - 1] );
	if( !xm ) return true;
	if( xm > 0 ) return sum ^ 1;
	return sum;
}

详细

implementer.cpp: In function ‘int _JFIBEIIYTAFEUXOULOWO_::main()’:
implementer.cpp:31:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   31 |                 auto [A,x,y,z]=V[i];
      |                      ^
implementer.cpp:36:18: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   36 |         for(auto [A,x,y]:U)
      |                  ^
implementer.cpp:39:22: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   39 |                 auto [A,x,y,z]=V[i];
      |                      ^
implementer.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d%d%d%d",&N,&Type,&p,&T);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
implementer.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |                 scanf("%llu",&x);
      |                 ~~~~~^~~~~~~~~~~
answer.code: In function ‘void init(int, bool, int)’:
answer.code:40:37: error: invalid types ‘int[int]’ for array subscript
   40 |         for(int i = 0; i < n; ++i) p[i].x = cos( alpha * i ), p[i].y = sin( alpha * i );
      |                                     ^
answer.code:40:64: error: invalid types ‘int[int]’ for array subscript
   40 |         for(int i = 0; i < n; ++i) p[i].x = cos( alpha * i ), p[i].y = sin( alpha * i );
      |                                                                ^