답안 #251382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251382 2020-07-21T04:53:51 Z jeqcho 가로등 (APIO19_street_lamps) C++17
20 / 100
121 ms 9480 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define f first
#define s second

int const N=3e5;
int base[N];
int tbase[N];
bitset<N> state;
int n,q;
string S;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>q;
//    F0R(i,n)
//    {
//        fill(base,base+n,0);
//        fill(tbase,tbase+n,0);
//    }
    cin>>S;
    F0R(i,n)
    {
        if(S[i]=='1')state[i]=1;
    }
    string typ;
    int i,a,b;
    int t=1;
    while(q--)
    {
        cin>>typ>>i;
        --i;
        if(typ[0]=='t')
        {
            base[i] += (state[i]) * (t - tbase[i]);
            state[i] = !state[i];
            tbase[i] = t;
        }
        else
        {
            cin>>b;
            cout<<base[i] + state[i] * (t - tbase[i])<<'\n';
        }
        ++t;
    }
    return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:44:11: warning: unused variable 'a' [-Wunused-variable]
     int i,a,b;
           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 1272 KB Output is correct
2 Correct 74 ms 1272 KB Output is correct
3 Correct 80 ms 1272 KB Output is correct
4 Correct 100 ms 8968 KB Output is correct
5 Correct 109 ms 9480 KB Output is correct
6 Correct 96 ms 8844 KB Output is correct
7 Correct 120 ms 7312 KB Output is correct
8 Correct 121 ms 8716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -