Submission #537560

#TimeUsernameProblemLanguageResultExecution timeMemory
537560jamezzzSecurity Gate (JOI18_security_gate)C++17
12 / 100
5092 ms300 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf int n,x,pos[25]; char s[105]; int main(){ sf("%d",&n); assert(n<=100); sf(" %s",&s); for(int i=0;i<n;++i){ if(s[i]=='x'){ pos[x]=i; ++x; } } assert(x<=20); int ans=0; for(int i=0;i<(1<<x);++i){ for(int j=0;j<x;++j){ if(i&(1<<j))s[pos[j]]=')'; else s[pos[j]]='('; } bool val=false; for(int i=0;i<n;++i){ for(int j=0;j<n;++j){ int cnt=0;bool pos=true; for(int k=0;k<n;++k){ int mult=1; if(i<=k&&k<=j)mult=-1; if(s[k]=='(')cnt+=mult; else cnt-=mult; if(cnt<0){ pos=false; break; } } if(cnt!=0)pos=false; if(pos){ val=true; break; } } if(val)break; } if(val)++ans; } pf("%d\n",ans); }

Compilation message (stderr)

securitygate.cpp: In function 'int main()':
securitygate.cpp:13:8: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[105]' [-Wformat=]
   13 |  sf(" %s",&s);
      |       ~^  ~~
      |        |  |
      |        |  char (*)[105]
      |        char*
securitygate.cpp:11:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  sf("%d",&n);
      |    ^
securitygate.cpp:13:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  sf(" %s",&s);
      |    ^
#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...