結果

問題 No.3024 等式
ユーザー kotatsugamekotatsugame
提出日時 2020-03-09 08:19:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,465 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 259,788 KB
最終ジャッジ日時 2024-04-25 10:11:26
合計ジャッジ時間 12,573 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 57 ms
9,056 KB
testcase_13 AC 56 ms
9,044 KB
testcase_14 AC 74 ms
10,148 KB
testcase_15 AC 76 ms
10,180 KB
testcase_16 AC 68 ms
10,116 KB
testcase_17 AC 62 ms
9,088 KB
testcase_18 AC 2,317 ms
207,172 KB
testcase_19 AC 2,327 ms
207,676 KB
testcase_20 AC 3,179 ms
259,788 KB
testcase_21 WA -
testcase_22 AC 2,560 ms
213,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~

ソースコード

diff #

#pragma GCC optimize("O3")
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
long gcd(long a,long b){return b?gcd(b,a%b):a;}
vector<pair<long,long> >M[1<<7];
int N;
long A[7];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		M[1<<i].push_back(make_pair(A[i],1));
	}
	for(int i=1;i+1<1<<N;i++)
	{
		for(int x=i&i-1;x>(i&~x);x=x-1&i)
		{
			int y=i&~x;
			for(const pair<long,long>&X:M[x])
			{
				for(const pair<long,long>&Y:M[y])
				{
					M[i].push_back(make_pair(X.first*Y.second+Y.first*X.second,X.second*Y.second));
					M[i].push_back(make_pair(X.first*Y.second-Y.first*X.second,X.second*Y.second));
					M[i].push_back(make_pair(-X.first*Y.second+Y.first*X.second,X.second*Y.second));
					M[i].push_back(make_pair(X.first*Y.first,X.second*Y.second));
					M[i].push_back(make_pair(X.first*Y.second,X.second*Y.first));
					M[i].push_back(make_pair(Y.first*X.second,Y.second*X.first));
				}
			}
		}
		for(pair<long,long>&p:M[i])
		{
			long g=gcd(p.first,p.second);
			p.first/=g;
			p.second/=g;
		}
		sort(M[i].begin(),M[i].end());
		M[i].erase(unique(M[i].begin(),M[i].end()),M[i].end());
	}
	for(int i=1;i+1<1<<N;i++)
	{
		int t=(1<<N)-1&~i;
		for(int j=t&t-1;j;j=j-1&t)
		{
			int ii=0,jj=0;
			while(ii<M[i].size()&&jj<M[j].size())
			{
				if(M[i][ii]==M[j][jj])
				{
					cout<<"YES"<<endl;
					return 0;
				}
				else if(M[i][ii]<M[j][jj])ii++;
				else jj++;
			}
		}
	}
	cout<<"NO"<<endl;
}
0