結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2015-10-12 10:11:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,168 bytes |
| コンパイル時間 | 1,467 ms |
| コンパイル使用メモリ | 166,748 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-21 07:15:48 |
| 合計ジャッジ時間 | 2,383 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
class TrendAndCountermeasures_PineDecorationSequence1 {
public:
void solve(void) {
int T;
cin>>T;
// O(T*N^2)
REP(t,T)
{
int N;
cin>>N;
using DecPine = vector<int>;
//typedef array<int,3> DecPine;
vector<DecPine> dec_pines;
REP(i,N)
{
int n = dec_pines.size();
int l,j;
bool update = false;
cin>>l;
for (j = 0; j < n; ++j)
{
auto &x = dec_pines[j];
// 同じ高さになってしまう
if ( any_of(RANGE(x),[l](int y){return y == l;}) )
continue;
// すでに門松ができている
if ( all_of(RANGE(x),[l](int y){return y > 0;}) )
continue;
REP(k,3)
{
if (x[k] > 0)
continue;
x[k] = l;
break;
}
update = true;
break;
}
if (!update)
dec_pines.push_back({l,-1,-1});
}
int cnt = 0;
for (auto x : dec_pines)
{
if (all_of(RANGE(x),[](int y){return y > 0;}))
++cnt;
}
cout<<cnt<<endl;
}
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new TrendAndCountermeasures_PineDecorationSequence1();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth