제출 #1126010

#제출 시각아이디문제언어결과실행 시간메모리
1126010luvna가로등 (APIO19_street_lamps)C++20
20 / 100
1 ms328 KiB
#include<bits/stdc++.h>

#define MASK(i) (1 << (i))
#define pub push_back
#define all(v) v.begin(), v.end()
#define compact(v) v.erase(unique(all(v)), end(v))
#define pii pair<int,int>
#define fi first
#define se second
#define endl "\n"
#define sz(v) (int)(v).size()
#define dbg(x) "[" #x " = " << (x) << "]"

using namespace std;

template<class T> bool minimize(T& a, T b){if(a > b) return a = b, true;return false;}
template<class T> bool maximize(T& a, T b){if(a < b) return a = b, true;return false;}

typedef long long ll;
typedef long double ld;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rand(ll l, ll r){return uniform_int_distribution<ll>(l, r)(rng);}

const int N = 3e5 + 15;

int n, q;
int a[N];

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

    int type[N], l[N], r[N];
    int b[N];

    void main(){
        for(int i = 1; i <= q; i++){
            string s; cin >> s;
            type[i] = (s == "toggle" ? 0 : 1);
            if(!type[i]){
                cin >> l[i];
            }
            else{
                cin >> l[i] >> r[i];
                for(int j = 1; j <= n; j++) b[j] = a[j];
                int ans = 0;
                for(int j = 0; j < i; j++){
                    if(j > 0 && !type[j]) b[l[j]] ^= 1;
                    bool ok = true;
                    for(int k = l[i]; k < r[i]; k++) ok &= b[k];
                    ans += ok;
                }
                cout << ans << endl;
            }
        }
    }
}

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

    for(int i = 1; i <= n; i++){
        char x; cin >> x;
        a[i] = x - '0';
    }

    if(subtask1::check()) subtask1::main();
}

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

    #define task "task"

    if(fopen(task".INP", "r")){
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }

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

컴파일 시 표준 에러 (stderr) 메시지

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen(task".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
street_lamps.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen(task".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...