Submission #79962
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include<bits/stdc++.h> using namespace std; #define int long long main(){ int n;cin>>n; int m=n/2; int a[m],b[m]; for ( int i=0;i<m;i++)cin>>a[i]; for ( int i=0;i<m;i++)cin>>b[i]; map<pair< int , int >, bool >ma; // 左半分で赤が青よりkey大きい時があるか for ( int i=0;i<(1<<m);i++){ int cour=1,coub=1; int red=0,blue=0; for ( int j=0;j<m;j++){ if (i&(1<<j)){ red+=a[j]*cour; cour++; } else { blue+=a[j]*coub; coub++; } } ma[{cour-1,red-blue}]= true ; //cout<<" "<<cour-1<<" "<<red-blue<<" "; } //cout<<" :a\n"; for ( int i=0;i<(1<<m);i++){ int bit=0,u=i; while (u!=0){ bit+=u%2; u/=2; } int cour=1+m-bit,coub=1+bit; int red=0,blue=0; for ( int j=0;j<m;j++){ if (i&(1<<j)){ red+=b[j]*cour; cour++; } else { blue+=b[j]*coub; coub++; } } if (ma.count({m-bit,blue-red})){ cout<< "Yes\n" ; return (0); } //cout<<" "<<bit<<" "<<blue-red<<" "; } //cout<<" :b\n"; cout<< "No\n" ; } |
ステータス
項目 | データ |
---|---|
問題 | 1815 - ボールの塗り分け |
ユーザー名 | ei2326 |
投稿日時 | 2024-07-17 23:10:13 |
言語 | C++17 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 1350 Byte |
最大実行時間 | 1043 ms |
最大メモリ使用量 | 66252 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in1.txt | AC | 189 ms | 4188 KB |
1
|
in2.txt | AC | 185 ms | 2544 KB |
1
|
in3.txt | AC | 19 ms | 612 KB |
1
|
in4.txt | AC | 720 ms | 66056 KB |
1
|
in5.txt | AC | 1025 ms | 66028 KB |
1
|
in6.txt | AC | 1043 ms | 66252 KB |
1
|
in7.txt | AC | 18 ms | 684 KB |
1
|
in8.txt | AC | 86 ms | 8704 KB |
1
|
in9.txt | AC | 27 ms | 480 KB |
1
|
in10.txt | AC | 20 ms | 424 KB |
1
|
in11.txt | AC | 26 ms | 396 KB |
1
|