답안 #73739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73739 2018-08-28T20:16:32 Z TadijaSebez Security Gate (JOI18_security_gate) C++11
12 / 100
5000 ms 848 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=105;
char s[N];
int n;
bool good(int l, int r)
{
	int c=0;
	for(int i=0;i<n;i++)
	{
		if(l<=i && i<=r)
		{
			if(s[i]==')') c++;
			else c--;
		}
		else
		{
			if(s[i]=='(') c++;
			else c--;
		}
		if(c<0) return 0;
	}
	return c==0;
}
bool Check()
{
	for(int i=0;i<n;i++) for(int j=i;j<n;j++) if(good(i,j)) return 1;
	if(good(0,-1)) return 1;
	return 0;
}
int main()
{
	int i,j,k=0;
	scanf("%i",&n);
	scanf("%s",s);
	vector<int> pos;
	for(i=0;i<n;i++) if(s[i]=='x') pos.pb(i),k++;
	int sol=0;
	if(k>20) return printf("0\n"),0;
	for(j=0;j<1<<k;j++)
	{
		for(i=0;i<k;i++) s[pos[i]]='('+((j>>i)&1);
		//cout << s << endl;
		if(Check()) sol++;
	}
	printf("%i\n",sol);
	return 0;
}

Compilation message

securitygate.cpp: In function 'int main()':
securitygate.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
securitygate.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s);
  ~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 4 ms 536 KB Output is correct
7 Correct 3 ms 628 KB Output is correct
8 Correct 4 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 632 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 6 ms 640 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 4 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 4 ms 536 KB Output is correct
7 Correct 3 ms 628 KB Output is correct
8 Correct 4 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 632 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 6 ms 640 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 4 ms 784 KB Output is correct
18 Correct 4 ms 784 KB Output is correct
19 Correct 17 ms 800 KB Output is correct
20 Correct 15 ms 800 KB Output is correct
21 Correct 622 ms 800 KB Output is correct
22 Correct 827 ms 800 KB Output is correct
23 Correct 15 ms 800 KB Output is correct
24 Correct 638 ms 820 KB Output is correct
25 Correct 4 ms 820 KB Output is correct
26 Correct 11 ms 820 KB Output is correct
27 Correct 488 ms 836 KB Output is correct
28 Correct 33 ms 836 KB Output is correct
29 Correct 7 ms 836 KB Output is correct
30 Correct 17 ms 836 KB Output is correct
31 Correct 98 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 4 ms 536 KB Output is correct
7 Correct 3 ms 628 KB Output is correct
8 Correct 4 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 632 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 6 ms 640 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 4 ms 784 KB Output is correct
18 Correct 4 ms 784 KB Output is correct
19 Correct 17 ms 800 KB Output is correct
20 Correct 15 ms 800 KB Output is correct
21 Correct 622 ms 800 KB Output is correct
22 Correct 827 ms 800 KB Output is correct
23 Correct 15 ms 800 KB Output is correct
24 Correct 638 ms 820 KB Output is correct
25 Correct 4 ms 820 KB Output is correct
26 Correct 11 ms 820 KB Output is correct
27 Correct 488 ms 836 KB Output is correct
28 Correct 33 ms 836 KB Output is correct
29 Correct 7 ms 836 KB Output is correct
30 Correct 17 ms 836 KB Output is correct
31 Correct 98 ms 848 KB Output is correct
32 Correct 192 ms 848 KB Output is correct
33 Correct 55 ms 848 KB Output is correct
34 Execution timed out 5020 ms 848 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 4 ms 536 KB Output is correct
7 Correct 3 ms 628 KB Output is correct
8 Correct 4 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 632 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 6 ms 640 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 4 ms 784 KB Output is correct
18 Correct 4 ms 784 KB Output is correct
19 Correct 17 ms 800 KB Output is correct
20 Correct 15 ms 800 KB Output is correct
21 Correct 622 ms 800 KB Output is correct
22 Correct 827 ms 800 KB Output is correct
23 Correct 15 ms 800 KB Output is correct
24 Correct 638 ms 820 KB Output is correct
25 Correct 4 ms 820 KB Output is correct
26 Correct 11 ms 820 KB Output is correct
27 Correct 488 ms 836 KB Output is correct
28 Correct 33 ms 836 KB Output is correct
29 Correct 7 ms 836 KB Output is correct
30 Correct 17 ms 836 KB Output is correct
31 Correct 98 ms 848 KB Output is correct
32 Correct 192 ms 848 KB Output is correct
33 Correct 55 ms 848 KB Output is correct
34 Execution timed out 5020 ms 848 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 4 ms 536 KB Output is correct
7 Correct 3 ms 628 KB Output is correct
8 Correct 4 ms 628 KB Output is correct
9 Correct 3 ms 628 KB Output is correct
10 Correct 3 ms 628 KB Output is correct
11 Correct 3 ms 632 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 6 ms 640 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 648 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 4 ms 784 KB Output is correct
18 Correct 4 ms 784 KB Output is correct
19 Correct 17 ms 800 KB Output is correct
20 Correct 15 ms 800 KB Output is correct
21 Correct 622 ms 800 KB Output is correct
22 Correct 827 ms 800 KB Output is correct
23 Correct 15 ms 800 KB Output is correct
24 Correct 638 ms 820 KB Output is correct
25 Correct 4 ms 820 KB Output is correct
26 Correct 11 ms 820 KB Output is correct
27 Correct 488 ms 836 KB Output is correct
28 Correct 33 ms 836 KB Output is correct
29 Correct 7 ms 836 KB Output is correct
30 Correct 17 ms 836 KB Output is correct
31 Correct 98 ms 848 KB Output is correct
32 Correct 192 ms 848 KB Output is correct
33 Correct 55 ms 848 KB Output is correct
34 Execution timed out 5020 ms 848 KB Time limit exceeded
35 Halted 0 ms 0 KB -