Submission #1867583
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
//* 便利な変数
namespace {
int dx4[] = { 1, -1, 0, 0 };
int dy4[] = { 0, 0, 1, -1 };
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };
int mDays[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
ll A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z;
}
template <typename T>
vector<T> INP(ll n)
{
vector<T> x;
REP(i, n) {
T tmp; cin >> tmp;
x.push_back(tmp);
}
return move(x);
}
//* n文字1行の文字列を入力,一文字ごとの配列を返す
vector<char> SPRIT_STRING(ll n)
{
string str; cin >> str;
vector<char> cs(n);
REP(i, n) cs[i] = str[i];
return move(cs);
}
//* 文字列中から文字列を検索して別の文字列に置換する
void strReplace(std::string& str, const std::string& from, const std::string& to) {
std::string::size_type pos = 0;
while (pos = str.find(from, pos), pos != std::string::npos) {
str.replace(pos, from.length(), to);
pos += to.length();
}
}
//* 素数判定 is_prime<unsigned>(N)
template<typename T, std::enable_if_t<std::is_unsigned<T>::value, std::nullptr_t> = nullptr>
bool is_prime(const T n) {
if (n < 4) return n == 2 || n == 3;
if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
for (T i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
//* 組み合わせ計算
inline unsigned long long NChooseK(const unsigned long long& n, const unsigned long long& k)
{
if (n < k) return 0;
if (0 == n) return 0;
if (0 == k) return 1;
if (n == k) return 1;
if (1 == k) return n;
typedef unsigned long long value_type;
value_type* table = new value_type[static_cast<std::size_t>(n * n)];
std::fill_n(table, n * n, 0);
class n_choose_k_impl
{
public:
n_choose_k_impl(value_type* table, const value_type& dimension)
: table_(table),
dimension_(dimension)
{}
inline value_type& lookup(const value_type& n, const value_type& k)
{
return table_[dimension_ * n + k];
}
inline value_type compute(const value_type& n, const value_type& k)
{
if ((0 == k) || (k == n))
return 1;
value_type v1 = lookup(n - 1, k - 1);
if (0 == v1)
v1 = lookup(n - 1, k - 1) = compute(n - 1, k - 1);
value_type v2 = lookup(n - 1, k);
if (0 == v2)
v2 = lookup(n - 1, k) = compute(n - 1, k);
return v1 + v2;
}
value_type* table_;
value_type dimension_;
};
value_type result = n_choose_k_impl(table, n).compute(n, k);
delete[] table;
return result;
}
//* 座標nx, nyがWidth,Heightの領域内にあるかどうかのチェック
inline bool rangeCheck2D(int nx, int ny, int Width, int Height)
{
return nx >= 0 and nx < Width and ny >= 0 and ny < Height;
}
//* bit全探索
/*
for (int i = 0; i < 1<<N; i++) {
REP(j, N)
if ((1 & i >> j) == 1) {;}
}
*/
namespace arc062a {
void arc062a()
{
cin >> N;
ll ct, ca;
REP(i, N) {
ll t, a; cin >> t >> a;
if (i == 0 or (t >= ct && a >= ca)) {
ct = t; ca = a;
}
else {
ll mult = 1, mula = 1;
if (t < ct)
mult = ct / t + ((ct%t == 0) ? 0 : 1);
if (a < ca)
mula = ca / a + ((ca%a == 0) ? 0 : 1);
ll mulv = max(mult, mula);
ct = t * mulv; ca = a * mulv;
}
}
cout << ct + ca << endl;
}
}
// 各辺を無効にしてみて幅優先探索
namespace abc075c {
void abc075c()
{
cin >> N >> M;
vector< pair<int, int> > es(M);
for (auto& e : es) {
int a, b; cin >> a >> b;
e.first = a - 1;
e.second = b - 1;
}
int cnt = 0;
REP(disNum, M) {
vector<bool> visited(N, false);
queue<int> ps;
ps.push(0);
while (not ps.empty()) {
int now = ps.front(); ps.pop();
visited[now] = true;
REP(i, M) {
if (i == disNum) continue;
pair<int, int> e = es[i];
if (e.first == now and not(visited[e.second]))
ps.push(e.second);
if (e.second == now and not(visited[e.first]))
ps.push(e.first);
}
}
bool okay = true;
REP(i, N)
if (not visited[i]) {
okay = false;
break;
}
if (okay)
cnt++;
}
cout << M - cnt << endl;
}
}
namespace abc065c {
bool dfs(int pos, string str)
{
if (pos == str.size()) return true;
bool okay = false;
if (pos + 7 <= str.size() and str.substr(pos, 7) == string("dreamer"))
okay |= dfs(pos + 7, str);
if (pos + 6 <= str.size() and str.substr(pos, 6) == string("eraser"))
okay |= dfs(pos + 6, str);
if (pos + 5 <= str.size()) {
string five = str.substr(pos, 5);
if (five == string("dream") or five == string("erase"))
okay |= dfs(pos + 5, str);
}
return okay;
}
void abc065c()
{
string str; cin >> str;
if (dfs(0, str))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
namespace abc066c {
}
int main()
{
//abc079b::abc079b();
abc065c::abc065c();
//arc062a::arc062a();
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Daydream |
User |
xoke |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
5245 Byte |
Status |
AC |
Exec Time |
18 ms |
Memory |
3712 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
subtask0_0.txt, subtask0_1.txt, subtask0_2.txt |
All |
subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask0_0.txt |
AC |
1 ms |
256 KB |
subtask0_1.txt |
AC |
1 ms |
256 KB |
subtask0_2.txt |
AC |
1 ms |
256 KB |
subtask1_0.txt |
AC |
7 ms |
1152 KB |
subtask1_1.txt |
AC |
9 ms |
1536 KB |
subtask1_10.txt |
AC |
17 ms |
3712 KB |
subtask1_11.txt |
AC |
17 ms |
3712 KB |
subtask1_12.txt |
AC |
17 ms |
3712 KB |
subtask1_13.txt |
AC |
17 ms |
3712 KB |
subtask1_14.txt |
AC |
12 ms |
2304 KB |
subtask1_15.txt |
AC |
9 ms |
1536 KB |
subtask1_2.txt |
AC |
18 ms |
3072 KB |
subtask1_3.txt |
AC |
17 ms |
3712 KB |
subtask1_4.txt |
AC |
5 ms |
640 KB |
subtask1_5.txt |
AC |
17 ms |
3712 KB |
subtask1_6.txt |
AC |
5 ms |
640 KB |
subtask1_7.txt |
AC |
5 ms |
640 KB |
subtask1_8.txt |
AC |
17 ms |
3712 KB |
subtask1_9.txt |
AC |
17 ms |
3712 KB |