답안 #721735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721735 2023-04-11T06:55:59 Z victor_gao 가로등 (APIO19_street_lamps) C++17
20 / 100
290 ms 23824 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 300015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
vector<int>all[N];
int n,q,ans[N];
bool arr[N];
signed main(){
    fast
    cin>>n>>q;
    for (int i=1;i<=n;i++){
        char c; cin>>c;
        arr[i]=c-'0';
        if (arr[i]==1)
            all[i].emplace_back(0);
        else {
            all[i].emplace_back(0);
            all[i].emplace_back(0);
        }
    }
    for (int t=1;t<=q;t++){
        string str; cin>>str;
        if (str=="toggle"){
            int i; cin>>i;
            if (arr[i]==0)
                all[i].emplace_back(t);
            else {
                ans[i]+=(t-all[i].back());
                all[i].emplace_back(t);
            }
            arr[i]^=1;
        }
        else {
            int l,r; cin>>l>>r;
            if (arr[l]==0) cout<<ans[l]<<'\n';
            else cout<<ans[l]+t-all[l].back()<<'\n';
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 10332 KB Output is correct
2 Correct 81 ms 10716 KB Output is correct
3 Correct 94 ms 11232 KB Output is correct
4 Correct 290 ms 23572 KB Output is correct
5 Correct 232 ms 22472 KB Output is correct
6 Correct 205 ms 23824 KB Output is correct
7 Correct 139 ms 18160 KB Output is correct
8 Correct 272 ms 19488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 7380 KB Output isn't correct
2 Halted 0 ms 0 KB -