Submission #1107051

# Submission time Handle Problem Language Result Execution time Memory
1107051 2024-10-31T13:11:30 Z InvMOD Street Lamps (APIO19_street_lamps) C++14
20 / 100
5000 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define gcd __gcd
#define sz(v) (int) v.size()
#define pb push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define compact(v) (v).erase(unique(all(v)), (v).end())
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define dbg(x) "[" #x " = " << (x) << "]"
///#define int long long

using ll = long long;
using ld = long double;
using ull = unsigned long long;

template<typename T> bool ckmx(T& a, const T& b){if(a < b) return a = b, true; return false;}
template<typename T> bool ckmn(T& a, const T& b){if(a > b) return a = b, true; return false;}

const int N = 3e5+5;
const ll MOD = 1e9+7;
const ll INF = 1e18;


int n, q;

namespace Subtask1{
    bool check(){return n <= 100 && q <= 100;}

    bool good(string& state, int l, int r){
        for(int i = l; i < r; i++)
            if(state[i] == '0') return false;
        return true;
    }

    void process()
    {
        string s; cin >> s;
        s = " " + s;

        vector<string> state(q+1);
        state[0] = s;

        for(int i = 1; i <= q; i++){
            string op; cin >> op;
            if(op == "toggle"){
                int idx; cin >> idx; // change type
                s[idx] = char((int(s[idx] - '0')^1) + '0');
                state[i] = s;
            }
            else{
                int l,r; cin >> l >> r;
                state[i] = s;

                int answer = 0;
                for(int j = 0; j < i; j++){
                    answer = answer + good(state[j], l, r);
                }

                cout << answer <<"\n";
            }
        }
    }
}

void solve()
{
    cin >> n >> q;

    Subtask1::process(); return;
    if(Subtask1::check()) Subtask1::process(), exit(0);
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    #define name "InvMOD"
    if(fopen(name".INP", "r")){
        freopen(name".INP","r",stdin);
        freopen(name".OUT","w",stdout);
    }

    int t = 1; //cin >> t;
    while(t--) solve();
    return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:85:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   85 |         freopen(name".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen(name".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5063 ms 20752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1360 KB Output is correct
2 Correct 3 ms 1360 KB Output is correct
3 Correct 3 ms 1360 KB Output is correct
4 Correct 80 ms 1412 KB Output is correct
5 Runtime error 353 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1360 KB Output is correct
2 Correct 2 ms 1360 KB Output is correct
3 Correct 3 ms 1488 KB Output is correct
4 Correct 2 ms 1360 KB Output is correct
5 Runtime error 353 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Execution timed out 5063 ms 20752 KB Time limit exceeded
9 Halted 0 ms 0 KB -