Submission #73733

# Submission time Handle Problem Language Result Execution time Memory
73733 2018-08-28T20:01:22 Z TadijaSebez Security Gate (JOI18_security_gate) C++11
0 / 100
3 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
string s;
const int N=105;
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;
	return 0;
}
int main()
{
	int i,j,k=0;
	scanf("%i",&n);
	cin >> 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);
		if(Check()) sol++;
	}
	printf("%i\n",sol);
	return 0;
}

Compilation message

securitygate.cpp: In function 'int main()':
securitygate.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -