Submission #1196902

#TimeUsernameProblemLanguageResultExecution timeMemory
1196902zaki98가로등 (APIO19_street_lamps)C++20
20 / 100
4857 ms589824 KiB
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) (c).begin(), (c).end()
#define pii pair<int,int>
#define pll pair<long long, long long>
#define sz(a) (int)a.size()
// permutation of the last layer
#define LOO(i,a,b) for (int i = a; i <= b; i++)
#define OOL(i,a,b) for (int i = b; i >= a; i--)
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
using namespace std;
typedef tree<int,null_type, less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
typedef tree<int,null_type, less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
constexpr ll MAX = 998244353;
void iO() {
    freopen("haircut.out", "w",stdout);
    freopen("haircut.in", "r",stdin);
}
vector<int> make_sorted_index(vector<int> const &values) {
    vector<int> index(values.size());
    iota(index.begin(), index.end(), 0);
    stable_sort(index.begin(), index.end(), [&values](int a, int b) {
        return values[a] < values[b];
    });
    return index;
} // this function is so skibidi
struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }

    int operator()(pii x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(FIXED_RANDOM * x.first + x.second + FIXED_RANDOM);
    }
}; // gp_hash_table custom hash so skibid

int solve() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<vector<int>> kid(n + 1, vector<int>(n + 1, 0));
    LOO(i, 0, q-1) {
        string s1;
        cin >> s1;
        LOO(j, 0, n) {
            LOO(k, j + 1, n) {
                if (s[k-1]=='0') break;
                kid[j][k]++;
            }
        }
        if (s1=="query") {
            int a, b;
            cin >> a >> b;
            a--;b--;
            cout << kid[a][b] << "\n";
        }
        else {
            int k;
            cin >> k;
            k--;
            s[k] = '0' + ('1'-s[k]);
        }

    }
    return 0;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 //   iO();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        //cout << flush;
    }
}

Compilation message (stderr)

street_lamps.cpp: In function 'void iO()':
street_lamps.cpp:24:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     freopen("haircut.out", "w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen("haircut.in", "r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...