結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
nanophoto12
|
| 提出日時 | 2016-08-15 14:46:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,657 bytes |
| 記録 | |
| コンパイル時間 | 778 ms |
| コンパイル使用メモリ | 89,308 KB |
| 実行使用メモリ | 817,824 KB |
| 最終ジャッジ日時 | 2024-11-07 17:41:46 |
| 合計ジャッジ時間 | 3,647 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 MLE * 1 -- * 26 |
ソースコード
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
#define ll long long int
#define ti4 tuple<int,int,int,int>
#define pii pair<ll,ll>
static const int MAX_N = 100000;
vector<int> g[MAX_N];
struct hist
{
int c;
int v[5];
bool ok(int n)
{
if(c != 5)
{
return false;
}
if(n == 1)
{
return true;
}
return false;
}
bool can(int n)
{
if(c >= 5)
{
return false;
}
for(int i = 0;i < c;i++)
{
if(v[i] == n)
{
return false;
}
}
return true;
}
int last() const
{
return v[c-1];
}
hist add(int n)
{
hist next = *this;
next.v[next.c] = n;
next.c++;
return next;
}
};
int main()
{
int n,m;
cin >> n >> m;
for(int i = 0;i < m;i++)
{
int f, s;
cin >> f >> s;
g[f].push_back(s);
g[s].push_back(f);
}
queue<hist> q;
q.push({1, 1});
while(!q.empty())
{
auto s = q.front();
q.pop();
for(auto& r : g[s.last()])
{
if(s.ok(r))
{
cout << "YES" << endl;
return 0;
}
if(!s.can(r))
{
continue;
}
q.push(s.add(r));
}
}
cout << "NO" << endl;
return 0;
}
nanophoto12