QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#513101#9168. Square Locatorucup-team3661#Compile Error//C++202.3kb2024-08-10 16:54:592024-08-10 16:54:59

Judging History

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

  • [2024-08-10 16:54:59]
  • 评测
  • [2024-08-10 16:54:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

int main(){
	vector<ll> LEN(4);
	for(int i = 0; i < 4; ++i) cin >> LEN[i];

	vector<int> p(4);
	iota(p.begin(), p.end(), 0);
	
	ll left = 1, right = 1000000010;
	while(right-left > 1){
		ll mid = (right+left)>>1;
		if(mid*mid > LEN[0]){
			right = mid;
		}else{
			left = mid;
		}
	}

	ll ay = left;

	do{
		if(p[0] != 0) break;
		ll BD = LEN[p[3]]-LEN[p[1]];
		if(BD%ay != 0) continue;
		if((BD/ay)%2 != 0) continue;
		__int128_t alpha = BD/ay/2;

		__int128_t CA = LEN[p[1]]-alpha*alpha-LEN[p[0]];
		if(CA%2 != 0) continue;
		__int128_t beta = -CA/2;

		__int128_t H = alpha+ay;
		H *= alpha+ay;
		H += -beta*4;

		__int128_t leftL = 1, rightL = 2000000000000000000LL;
		while(rightL-leftL > 1){
			__int128_t mid = (leftL+rightL)>>1;
			if(mid*mid > H){
				rightL = mid;
			}else{
				leftL = mid;
			}
		}
		if(leftL*leftL != H) continue;

		if(abs(leftL+alpha)&1) continue;

		{
			ll ly = (leftL-alpha-ay)/2;
			ll lx = alpha+ly;

			vector<ll> ansx(4), ansy(4);
			ansx[p[0]] = 0;
			ansx[p[1]] = ansx[p[0]] + lx;
			ansx[p[2]] = ansx[p[0]] + lx - ly;
			ansx[p[3]] = ansx[p[0]] - ly;
			ansy[p[0]] = ay;
			ansy[p[1]] = ansy[p[0]] + ly;
			ansy[p[2]] = ansy[p[0]] + lx + ly;
			ansy[p[3]] = ansy[p[0]] + lx;
			
			bool flag = true;
			for(int i = 0; i < 4; ++i){
				flag &= (ansx[i]*ansx[i]+ansy[i]*ansy[i]) == LEN[i];
			}
			if(true){
				cout << ansy[0] << ' ' << ansx[1] << ' ' << ansy[1] << ' ' << ansx[2] << ' ' << ansy[2] << ' ' << ansx[3] << ' ' << ansy[3] << endl;
				return 0;
			}
		}

		{
			ll ly = (-leftL-alpha-ay)/2;
			ll lx = alpha+ly;

			vector<ll> ansx(4), ansy(4);
			ansx[p[0]] = 0;
			ansx[p[1]] = ansx[p[0]] + lx;
			ansx[p[2]] = ansx[p[0]] + lx - ly;
			ansx[p[3]] = ansx[p[0]] - ly;
			ansy[p[0]] = ay;
			ansy[p[1]] = ansy[p[0]] + ly;
			ansy[p[2]] = ansy[p[0]] + lx + ly;
			ansy[p[3]] = ansy[p[0]] + lx;
			
			bool flag = true;
			for(int i = 0; i < 4; ++i){
				flag &= (ansx[i]*ansx[i]+ansy[i]*ansy[i]) == LEN[i];
			}
			if(true){
				cout << ansy[0] << ' ' << ansx[1] << ' ' << ansy[1] << ' ' << ansx[2] << ' ' << ansy[2] << ' ' << ansx[3] << ' ' << ansy[3] << endl;
				return 0;
			}
		}

	}while(next_permutation(p.begin(), p.end()));
	assert(false);
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:51:23: error: call of overloaded ‘abs(__int128)’ is ambiguous
   51 |                 if(abs(leftL+alpha)&1) continue;
      |                    ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/13/cstdlib:81:
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:61:3: note: candidate: ‘long long int std::abs(long long int)’
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~