답안 #392060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
392060 2021-04-20T11:06:22 Z A_D Paint (COI20_paint) C++14
0 / 100
48 ms 908 KB
#include <bits/stdc++.h>
//#define int long long
#define ii pair<int,int>
#define F first
#define S second
#define du long double
using namespace std;
const int N=2e5+100;
int a[N];
int l[N];
int r[N];
int n;
int fl(int u)
{
    if(u==l[u]){
        if(u==1)return u;
        if(a[u-1]!=a[u]){
            return u;
        }
        else{
            r[u-1]=min(r[u-1],r[u]);
            return l[u]=fl(u-1);
        }
    }
    return l[u]=fl(l[u]);
}
int fr(int u)
{
    if(u==r[u]){
        if(u==n)return u;
        if(a[u+1]!=a[u]){
            return u;
        }
        else{
            l[u+1]=min(l[u+1],l[u]);
            return r[u]=fr(u+1);
        }
    }
    return r[u]=fr(r[u]);
}
void solve()
{
    cin>>n>>n;
    for(int i=1;i<=n;i++){
        l[i]=i;
        r[i]=i;
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        l[i]=fl(i);
        r[i]=fr(i);
    }
    int q;
    cin>>q;
    while(q--){
        int i,c;
        scanf("%d",&i);
        scanf("%d",&i);
        scanf("%d",&c);
        l[i]=fl(i);
        r[i]=fr(i);
        a[l[i]]=c;
        a[r[i]]=c;
    }
    for(int i=1;i<=n;i++){
        int ans=fl(i);
        ans=a[ans];
        printf("%d ",ans);
    }
}
main()
{
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    int t=1;
//    cin>>t;
    while(t--)solve();
}

Compilation message

paint.cpp:71:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   71 | main()
      |      ^
paint.cpp: In function 'void solve()':
paint.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   47 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
paint.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   57 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
paint.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   58 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
paint.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   59 |         scanf("%d",&c);
      |         ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -