Submission #412048

# Submission time Handle Problem Language Result Execution time Memory
412048 2021-05-26T12:41:10 Z 반딧불(#7584) Paint (COI20_paint) C++17
0 / 100
3000 ms 204 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
#define LIM 5
#define MAX 200

using namespace std;

typedef long long ll;

int n, m;
int arr[MAX];
set<int> st;

void input(){
    scanf("%d %d", &n, &m);
    for(int i=0; i<m; i++) scanf("%d", &arr[i]);
    for(int i=0; i<m; i++){
        if(i==0 || arr[i] != arr[i-1]) st.insert(i);
    }
}

void operate(){
    int q;
    scanf("%d", &q);
    while(q--){
        int p, c;
        scanf("%d %d %d", &p, &p, &c);
        p--;
        p = *st.lower_bound(p);
        arr[p] = c;

        auto it = st.lower_bound(p);
        if(next(it) != st.end() && arr[*next(it)] == c) st.erase(next(it));
        if(it != st.begin() && arr[*prev(it)] == c) st.erase(it);
    }
}

void output(){
    for(int i=0; i<n*m; i++){
        printf("%d ", arr[*st.lower_bound(i)]);
    }
}

int main(){
    input();
    operate();
    output();
}

Compilation message

paint.cpp: In function 'void input()':
paint.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
paint.cpp:18:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     for(int i=0; i<m; i++) scanf("%d", &arr[i]);
      |                            ~~~~~^~~~~~~~~~~~~~~
paint.cpp: In function 'void operate()':
paint.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
paint.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d %d %d", &p, &p, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3073 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -