Submission #432828

#TimeUsernameProblemLanguageResultExecution timeMemory
432828Amylopectin가로등 (APIO19_street_lamps)C++14
20 / 100
5083 ms4328 KiB
#include <iostream> #include <stdio.h> using namespace std; const int mxn = 1010; char s[mxn] = {},inp[mxn] = {}; struct we { int tim,sta; }; struct we li[mxn][mxn] = {}; int coun[mxn] = {},cva[mxn] = {}; int main() { int i,j,n,m,q,f,t,cst,cou,su,k; scanf("%d %d %s",&n,&q,&s); for(i=0; i<n; i++) { li[i][0] = {0,s[i] - '0'}; coun[i] = 1; } for(i=1; i<=q; i++) { scanf("%s",&inp); if(inp[0] == 't') { scanf("%d",&f); f --; li[f][coun[f]] = {i,(li[f][coun[f]-1].sta + 1) % 2}; coun[f] ++; } else { scanf("%d %d",&f,&t); f --; t --; for(j=1; j<=i; j++) { cva[j] = 1; } for(j=f; j<t; j++) { cst = li[j][0].sta; cou = 1; // cva[0] &= cst; for(k=1; k<=i; k++) { cva[k] &= cst; if(cou < coun[j] && li[j][cou].tim == k) { cst = (cst+1) % 2; cou ++; } } } su = 0; for(k=1; k<=i; k++) { su += cva[k]; } printf("%d\n",su); } } return 0; }

Compilation message (stderr)

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:15:19: warning: format '%s' expects argument of type 'char*', but argument 4 has type 'char (*)[1010]' [-Wformat=]
   15 |     scanf("%d %d %s",&n,&q,&s);
      |                  ~^        ~~
      |                   |        |
      |                   char*    char (*)[1010]
street_lamps.cpp:23:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[1010]' [-Wformat=]
   23 |         scanf("%s",&inp);
      |                ~^  ~~~~
      |                 |  |
      |                 |  char (*)[1010]
      |                 char*
street_lamps.cpp:14:15: warning: unused variable 'm' [-Wunused-variable]
   14 |     int i,j,n,m,q,f,t,cst,cou,su,k;
      |               ^
street_lamps.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d %d %s",&n,&q,&s);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%s",&inp);
      |         ~~~~~^~~~~~~~~~~
street_lamps.cpp:26:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |             scanf("%d",&f);
      |             ~~~~~^~~~~~~~~
street_lamps.cpp:33:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |             scanf("%d %d",&f,&t);
      |             ~~~~~^~~~~~~~~~~~~~~
#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...