답안 #432833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432833 2021-06-18T13:54:00 Z Amylopectin 가로등 (APIO19_street_lamps) C++14
0 / 100
111 ms 23804 KB
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
const int mxn = 800010;
char s[mxn] = {},inp[mxn] = {};
struct we
{
    int tim,sta;
};
vector<struct we> li[mxn] = {};
//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'};
        li[i].push_back({0,s[i] - '0'});
//        coun[i] = 1;
    }
    for(i=1; i<=q; i++)
    {
        scanf("%s",&inp);
        if(inp[0] == 't')
        {
            scanf("%d",&f);
            f --;
            if(li[f][li[f].size()-1].sta == 1)
            {
                cva[f] += i - li[f][li[f].size()-1].tim;
            }
            li[f].push_back({i,(li[f][coun[f]-1].sta + 1) % 2});
//            li[f][coun[f]] = {i,(li[f][coun[f]-1].sta + 1) % 2};
//            coun[f] ++;
        }
        else
        {
            scanf("%d %d",&f,&t);
            f --;
            t --;
            su = cva[f];
            if(li[f][li[f].size()-1].sta == 1)
            {
                su += i - li[f][li[f].size()-1].tim;
            }
//            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

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:17:19: warning: format '%s' expects argument of type 'char*', but argument 4 has type 'char (*)[800010]' [-Wformat=]
   17 |     scanf("%d %d %s",&n,&q,&s);
      |                  ~^        ~~
      |                   |        |
      |                   char*    char (*)[800010]
street_lamps.cpp:26:17: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[800010]' [-Wformat=]
   26 |         scanf("%s",&inp);
      |                ~^  ~~~~
      |                 |  |
      |                 |  char (*)[800010]
      |                 char*
street_lamps.cpp:16:11: warning: unused variable 'j' [-Wunused-variable]
   16 |     int i,j,n,m,q,f,t,cst,cou,su,k;
      |           ^
street_lamps.cpp:16:15: warning: unused variable 'm' [-Wunused-variable]
   16 |     int i,j,n,m,q,f,t,cst,cou,su,k;
      |               ^
street_lamps.cpp:16:23: warning: unused variable 'cst' [-Wunused-variable]
   16 |     int i,j,n,m,q,f,t,cst,cou,su,k;
      |                       ^~~
street_lamps.cpp:16:27: warning: unused variable 'cou' [-Wunused-variable]
   16 |     int i,j,n,m,q,f,t,cst,cou,su,k;
      |                           ^~~
street_lamps.cpp:16:34: warning: unused variable 'k' [-Wunused-variable]
   16 |     int i,j,n,m,q,f,t,cst,cou,su,k;
      |                                  ^
street_lamps.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d %d %s",&n,&q,&s);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf("%s",&inp);
      |         ~~~~~^~~~~~~~~~~
street_lamps.cpp:29:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |             scanf("%d",&f);
      |             ~~~~~^~~~~~~~~
street_lamps.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |             scanf("%d %d",&f,&t);
      |             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 19020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 111 ms 23804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 19020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 19020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 19020 KB Output isn't correct
2 Halted 0 ms 0 KB -