답안 #934366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934366 2024-02-27T08:22:39 Z vjudge1 가로등 (APIO19_street_lamps) C++17
20 / 100
5000 ms 524288 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;
    int ans[n+1][n+1] = {};
    string s; cin >> s; int siz = s.size();
    int arr[siz];
    for(int i = 0; i < s.size(); i++) {
        arr[i] = s[i]-'0';
    }
    while(q--) {
        string ty; cin >> ty;
        for(int i = 0; i < n; i++) {
            for(int j = i+1; j < n+1; j++) {
                bool ok = true;
                for(int z = i; z <= j-1; z++) {
                    if(arr[z] == 0) {
                        ok = false;
                        break;
                    }
                }
                if(ok) {
                    ans[i][j]++;
                }
            }
        }
        if(ty == "toggle") {
            int x; cin >> x;
            arr[x-1] = abs(1-arr[x-1]);
        }
        else {
            int a, b; cin >> a >> b;
            cout << ans[a-1][b-1] << endl;
        }
    }
    return 0;
}

Compilation message

street_lamps.cpp: In function 'int main()':
street_lamps.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < s.size(); i++) {
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 12 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2738 ms 4600 KB Output is correct
2 Execution timed out 5009 ms 2124 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1497 ms 4364 KB Output is correct
2 Correct 1927 ms 4432 KB Output is correct
3 Correct 2985 ms 4364 KB Output is correct
4 Execution timed out 5047 ms 4188 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 722 ms 4436 KB Output is correct
2 Correct 728 ms 4364 KB Output is correct
3 Correct 728 ms 4364 KB Output is correct
4 Correct 794 ms 4360 KB Output is correct
5 Runtime error 320 ms 524288 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 12 ms 348 KB Output is correct
8 Correct 2738 ms 4600 KB Output is correct
9 Execution timed out 5009 ms 2124 KB Time limit exceeded
10 Halted 0 ms 0 KB -