Submission #47763

#TimeUsernameProblemLanguageResultExecution timeMemory
47763daniel_02Security Gate (JOI18_security_gate)C++17
12 / 100
5017 ms860 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; const int N = 305; int ans, pr[N]; vector<int>dam; bool ch(string s) { int sm = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') sm ++; else sm--; if (sm < 0) { return 0; } } if (sm == 0)return 1; return 0; } bool check(string s) { string s1; s1 = s; if (ch(s)) { return 1; } for (int i = 0; i < s.size(); i++) { for (int j = i; j < s.size(); j++) { if (s1[j] == ')') s1[j] = '('; else s1[j] = ')'; if (ch(s1)) { return 1; } } s1 = s; } return 0; } main() { int n; cin >> n; string s, s1; cin >> s; s1 = s; for (int i = 0; i < s.size(); i++) { if (s[i] == 'x') { dam.pb(i); } } for (int msk = 0; msk < (1 << int(dam.size())); msk ++) { for (int i = 0; i < dam.size(); i++) { if (msk & (1 << i)) s1[dam[i]] = '('; else s1[dam[i]] = ')'; } if (check(s1)) { ans++; } } cout << ans; }

Compilation message (stderr)

securitygate.cpp: In function 'bool ch(std::__cxx11::string)':
securitygate.cpp:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++)
                     ~~^~~~~~~~~~
securitygate.cpp: In function 'bool check(std::__cxx11::string)':
securitygate.cpp:40:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++)
                     ~~^~~~~~~~~~
securitygate.cpp:42:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i; j < s.size(); j++)
                         ~~^~~~~~~~~~
securitygate.cpp: At global scope:
securitygate.cpp:58:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
securitygate.cpp: In function 'int main()':
securitygate.cpp:69:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++)
                     ~~^~~~~~~~~~
securitygate.cpp:79:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < dam.size(); i++)
                         ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...