답안 #72307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72307 2018-08-26T06:59:41 Z RR rangers(#2172, jwvg0425, ozt88, choy907) 디스토브 (FXCUP3_dstorv) C++17
컴파일 오류
0 ms 0 KB
��#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>
#define MOD ((i64)(1e9+7))

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

// table[r][h] = Rt� r�, H� h� ��D� L� X�� 0��  � U�`�
i64 table[5001][5001];

i64 ipow(i64 x, i64 k)
{
	if (k == 0)
		return 1;

	i64 half = ipow(x, k / 2);

	half = (half * half) % MOD;

	if (k % 2 == 0)
		return half;
	else
		return (half * x) % MOD;
}


int main()

{

	int n, r, h;

	scanf("%d %d %d", &n, &r, &h);



	string s;



	cin >> s;



	table[0][0] = 1;



	i64 flowerp, handp;

	i64 denom = ipow(r + h, MOD - 2);



	flowerp = (h * denom) % MOD;

	handp = (r * denom) % MOD;



	for(int flower = 0; flower <= n; flower ++)

	{

		for(int hand = 0; hand <= n; hand++)

		{

			if (flower == 0 && hand == 0)

				continue;



			table[flower][hand] = 1;

			

			if (flower > 0)

				table[flower][hand] = handp * table[flower - 1][hand];



			if (hand > 0)

				table[flower][hand] = flowerp * table[flower][hand - 1];

		}

	}



	int a, b;

	scanf("%d %d", &a, &b);



	i64 ans = 0;

	for (int i = 0; i < s.size() - 1; i++)

	{

		if (s[i] != 'H' || s[i + 1] != 'R')

			continue;



		int leftmost = -1;

		for (int j = 0; j <= i; j++)

		{

			if (s[j] == 'R')

			{

				leftmost = j;

				break;

			}

		}



		i64 leftp = 1;

		int hl = 0, hr = 0;

		int remainr = 0;



		for (int j = 0; j <= i; j++)

		{

			if (s[j] != 'H')

			{

				remainr++;

				continue;

			}



			if (j <= leftmost)

				hl++;

			else

				hr++;

		}



		if (leftmost == -1)

		{

			if (hl != b)

				continue;

		}

		else

		{

			int remain = b - hl;



			if (remain < 0)

				continue;



			int need = hr - remain;



			leftp = table[remainr][need];

		}



		i64 rightp = 1;



		int rightmost = -1;

		for (int j = n - 1; j > i; j--)

		{

			if (s[j] == 'H')

			{

				rightmost = j;

				break;

			}

		}



		int rl = 0, rr = 0;

		int remainh = 0;



		for (int j = n - 1; j > i ; j--)

		{

			if (s[j] != 'R')

			{

				remainh++;

				continue;

			}



			if (j >= rightmost)

				rr++;

			else

				rl++;

		}



		if (rightmost == -1)

		{

			if (rr != a)

				continue;

		}

		else

		{

			int remain = a - rr;



			if (remain < 0)

				continue;



			int need = rl - remain;



			rightp = table[need][remainh];

		}



		i64 p = (leftp * rightp) % MOD;



		ans = (ans + p) % MOD;

	}



	printf("%lld\n", ans);



	return 0;

}

Compilation message

dstorv.cpp:1:1: error: stray '\377' in program
 # i n c l u d e   < s t d i o . h > 
 ^
dstorv.cpp:1:2: error: stray '\376' in program
 # i n c l u d e   < s t d i o . h > 
  ^
dstorv.cpp:1:3: error: stray '#' in program
 # i n c l u d e   < s t d i o . h > 
   ^
dstorv.cpp:1:4: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
    ^
dstorv.cpp:1:6: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
      ^
dstorv.cpp:1:8: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
        ^
dstorv.cpp:1:10: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
          ^
dstorv.cpp:1:12: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
            ^
dstorv.cpp:1:14: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
              ^
dstorv.cpp:1:16: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                ^
dstorv.cpp:1:18: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                  ^
dstorv.cpp:1:22: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                      ^
dstorv.cpp:1:24: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                        ^
dstorv.cpp:1:26: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                          ^
dstorv.cpp:1:28: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                            ^
dstorv.cpp:1:30: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                              ^
dstorv.cpp:1:32: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                                ^
dstorv.cpp:1:34: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                                  ^
dstorv.cpp:1:36: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                                    ^
dstorv.cpp:1:38: warning: null character(s) ignored
 # i n c l u d e   < s t d i o . h > 
                                      ^
dstorv.cpp:2:1: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
 ^
dstorv.cpp:2:3: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
   ^
dstorv.cpp:2:4: error: invalid preprocessing directive #i; did you mean #if?
  # i n c l u d e   < v e c t o r > 
    ^
    if
dstorv.cpp:2:5: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
     ^
dstorv.cpp:2:7: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
       ^
dstorv.cpp:2:9: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
         ^
dstorv.cpp:2:11: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
           ^
dstorv.cpp:2:13: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
             ^
dstorv.cpp:2:15: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
               ^
dstorv.cpp:2:17: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                 ^
dstorv.cpp:2:21: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                     ^
dstorv.cpp:2:23: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                       ^
dstorv.cpp:2:25: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                         ^
dstorv.cpp:2:27: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                           ^
dstorv.cpp:2:29: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                             ^
dstorv.cpp:2:31: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                               ^
dstorv.cpp:2:33: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                                 ^
dstorv.cpp:2:35: warning: null character(s) ignored
  # i n c l u d e   < v e c t o r > 
                                   ^
dstorv.cpp:3:1: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
 ^
dstorv.cpp:3:3: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
   ^
dstorv.cpp:3:4: error: invalid preprocessing directive #i; did you mean #if?
  # i n c l u d e   < q u e u e > 
    ^
    if
dstorv.cpp:3:5: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
     ^
dstorv.cpp:3:7: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
       ^
dstorv.cpp:3:9: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
         ^
dstorv.cpp:3:11: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
           ^
dstorv.cpp:3:13: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
             ^
dstorv.cpp:3:15: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
               ^
dstorv.cpp:3:17: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                 ^
dstorv.cpp:3:21: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                     ^
dstorv.cpp:3:23: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                       ^
dstorv.cpp:3:25: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                         ^
dstorv.cpp:3:27: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                           ^
dstorv.cpp:3:29: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                             ^
dstorv.cpp:3:31: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                               ^
dstorv.cpp:3:33: warning: null character(s) ignored
  # i n c l u d e   < q u e u e > 
                                 ^
dstorv.cpp:4:1: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
 ^
dstorv.cpp:4:3: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
   ^
dstorv.cpp:4:4: error: invalid preprocessing directive #i; did you mean #if?
  # i n c l u d e   < a l g o r i t h m > 
    ^
    if
dstorv.cpp:4:5: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
     ^
dstorv.cpp:4:7: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
       ^
dstorv.cpp:4:9: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
         ^
dstorv.cpp:4:11: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
           ^
dstorv.cpp:4:13: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
             ^
dstorv.cpp:4:15: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
               ^
dstorv.cpp:4:17: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                 ^
dstorv.cpp:4:21: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                     ^
dstorv.cpp:4:23: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                       ^
dstorv.cpp:4:25: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                         ^
dstorv.cpp:4:27: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                           ^
dstorv.cpp:4:29: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                             ^
dstorv.cpp:4:31: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                               ^
dstorv.cpp:4:33: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                                 ^
dstorv.cpp:4:35: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                                   ^
dstorv.cpp:4:37: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                                     ^
dstorv.cpp:4:39: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                                       ^
dstorv.cpp:4:41: warning: null character(s) ignored
  # i n c l u d e   < a l g o r i t h m > 
                                         ^
dstorv.cpp:5:1: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
 ^
dstorv.cpp:5:3: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
   ^
dstorv.cpp:5:4: error: invalid preprocessing directive #i; did you mean #if?
  # i n c l u d e   < i o s t r e a m > 
    ^
    if
dstorv.cpp:5:5: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
     ^
dstorv.cpp:5:7: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
       ^
dstorv.cpp:5:9: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
         ^
dstorv.cpp:5:11: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
           ^
dstorv.cpp:5:13: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
             ^
dstorv.cpp:5:15: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
               ^
dstorv.cpp:5:17: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                 ^
dstorv.cpp:5:21: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                     ^
dstorv.cpp:5:23: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                       ^
dstorv.cpp:5:25: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                         ^
dstorv.cpp:5:27: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                           ^
dstorv.cpp:5:29: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                             ^
dstorv.cpp:5:31: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                               ^
dstorv.cpp:5:33: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                                 ^
dstorv.cpp:5:35: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                                   ^
dstorv.cpp:5:37: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                                     ^
dstorv.cpp:5:39: warning: null character(s) ignored
  # i n c l u d e   < i o s t r e a m > 
                                       ^
dstorv.cpp:6:1: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
 ^
dstorv.cpp:6:3: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
   ^
dstorv.cpp:6:4: error: invalid preprocessing directive #i; did you mean #if?
  # i n c l u d e   < s t r i n g > 
    ^
    if
dstorv.cpp:6:5: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
     ^
dstorv.cpp:6:7: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
       ^
dstorv.cpp:6:9: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
         ^
dstorv.cpp:6:11: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
           ^
dstorv.cpp:6:13: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
             ^
dstorv.cpp:6:15: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
               ^
dstorv.cpp:6:17: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                 ^
dstorv.cpp:6:21: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                     ^
dstorv.cpp:6:23: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                       ^
dstorv.cpp:6:25: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                         ^
dstorv.cpp:6:27: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                           ^
dstorv.cpp:6:29: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                             ^
dstorv.cpp:6:31: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                               ^
dstorv.cpp:6:33: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                                 ^
dstorv.cpp:6:35: warning: null character(s) ignored
  # i n c l u d e   < s t r i n g > 
                                   ^
dstorv.cpp:7:1: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
 ^
dstorv.cpp:7:3: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
   ^
dstorv.cpp:7:4: error: invalid preprocessing directive #i; did you mean #if?
  # i n c l u d e   < b i t s e t > 
    ^
    if
dstorv.cpp:7:5: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
     ^
dstorv.cpp:7:7: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
       ^
dstorv.cpp:7:9: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
         ^
dstorv.cpp:7:11: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
           ^
dstorv.cpp:7:13: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
             ^
dstorv.cpp:7:15: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
               ^
dstorv.cpp:7:17: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                 ^
dstorv.cpp:7:21: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                     ^
dstorv.cpp:7:23: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                       ^
dstorv.cpp:7:25: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                         ^
dstorv.cpp:7:27: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                           ^
dstorv.cpp:7:29: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                             ^
dstorv.cpp:7:31: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                               ^
dstorv.cpp:7:33: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                                 ^
dstorv.cpp:7:35: warning: null character(s) ignored
  # i n c l u d e   < b i t s e t > 
                                   ^
dstorv.cpp:8:1: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
 ^
dstorv.cpp:8:3: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
   ^
dstorv.cpp:8:4: error: invalid preprocessing directive #i; did you mean #if?
  # i n c l u d e   < m a p > 
    ^
    if
dstorv.cpp:8:5: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
     ^
dstorv.cpp:8:7: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
       ^
dstorv.cpp:8:9: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
         ^
dstorv.cpp:8:11: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
           ^
dstorv.cpp:8:13: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
             ^
dstorv.cpp:8:15: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
               ^
dstorv.cpp:8:17: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
                 ^
dstorv.cpp:8:21: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
                     ^
dstorv.cpp:8:23: warning: null character(s) ignored
  # i n c l u d e   < m a p > 
                       ^
dstorv.cpp:8:25: warning: null character(s)