답안 #934373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934373 2024-02-27T08:45:08 Z vjudge1 가로등 (APIO19_street_lamps) C++17
20 / 100
91 ms 12264 KB
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 1000000007
#define INF 1000000000
#define INF2 2000000000000000000
//#define ll long long
///#define cin fin
///#define cout fout
using namespace std;
double const EPS = 1e-14;
///ofstream fout("herding.out");
///ifstream fin("herding.in");

int main()
{
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    int n, q; cin >> n >> q;
    string s; cin >> s; int siz = s.size();
    int arr[siz], sum[siz] = {}, last[siz] = {};
    for(int i = 0; i < s.size(); i++) {
        arr[i] = s[i]-'0';
    }
    int cnt = 1;
    while(q--) {
        string ty; cin >> ty;
        if(ty == "toggle") {
            int x; cin >> x;
            sum[x-1] += (cnt-last[x-1])*arr[x-1];
            last[x-1] = cnt;
            arr[x-1] = abs(1-arr[x-1]);
        }
        else {
            int a, b; cin >> a >> b;
            sum[a-1] += (cnt-last[a-1])*arr[a-1];
            last[a-1] = cnt;
            cout << sum[a-1] << endl;
        }
        cnt++;
    }
    return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i = 0; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 3056 KB Output is correct
2 Correct 54 ms 4436 KB Output is correct
3 Correct 57 ms 5200 KB Output is correct
4 Correct 66 ms 9988 KB Output is correct
5 Correct 69 ms 10468 KB Output is correct
6 Correct 62 ms 9960 KB Output is correct
7 Correct 81 ms 10836 KB Output is correct
8 Correct 91 ms 12264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -