Submission #240119

# Submission time Handle Problem Language Result Execution time Memory
240119 2020-06-18T06:23:41 Z wiwiho Street Lamps (APIO19_street_lamps) C++14
20 / 100
5000 ms 524292 KB
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n, q;
    cin >> n >> q;

    vector<string> s(q + 1);
    cin >> s[0];
    for(int i = 0; i < q; i++){
        string t;
        cin >> t;
        s[i + 1] = s[i];

        if(t == "toggle"){
            int x;
            cin >> x;
            x--;
            if(s[i + 1][x] == '0') s[i + 1][x] = '1';
            else s[i + 1][x] = '0';
        }
        else{
            int a, b;
            cin >> a >> b;
            a--; b--;
            int ans = 0;

            for(int j = 0; j <= i; j++){
                bool tmp = true;
                for(int k = a; k < b; k++){
                    if(s[j][k] == '0') tmp = false;
                }
                ans += tmp;
            }
            cout << ans << "\n";
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5053 ms 18204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1280 KB Output is correct
2 Correct 34 ms 1400 KB Output is correct
3 Correct 60 ms 1400 KB Output is correct
4 Correct 101 ms 1400 KB Output is correct
5 Runtime error 966 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 100 ms 1400 KB Output is correct
2 Correct 92 ms 1528 KB Output is correct
3 Correct 58 ms 1400 KB Output is correct
4 Correct 10 ms 1408 KB Output is correct
5 Runtime error 397 ms 524292 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Execution timed out 5053 ms 18204 KB Time limit exceeded
9 Halted 0 ms 0 KB -