# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
69462 | mohazar | Security Gate (JOI18_security_gate) | C++14 | 2 ms | 488 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mod 998244353
using namespace std;
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/
int n;
string s;
int a[305];
vector<int> ini;
bool check(){
int pref = 0;
for(int i = 0; i < n; i++){
pref = pref + a[i];
if(pref < 0) return false;
}
if(pref == 0) return true;
return false;
}
int main(){
cin >> n;
cin >> s;
if(n % 2 == 1){
cout << "0\n";
return 0;
}
int nyak = 0;
for(int i = 0; i < n; i++){
if(s[i] == 'x'){
ini.pb(i);
nyak++;
}else if(s[i] == '('){
a[i] = 1;
}else{
a[i] = -1;
}
}
int maks = (1 << nyak);
int cnt = 0;
for(int i = 0; i < maks; i++){
for(int j = 0; j < ini.size(); j++){
int pos = ini[j];
if((i & (1 << j)) > 0){
a[pos] = 1;
}else{
a[pos] = -1;
}
}
bool bisa = false;
for(int p = 0; p < n; p++){
for(int q = p; q < n; q++){
for(int r = p; r <= q; r++) a[r] = -a[r];
if(check()) bisa = true;
for(int r = p; r <= q; r++) a[r] = -a[r];
if(bisa) break;
}
if(bisa) break;
}
if(bisa){
cnt++;
}
}
cout << cnt << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |