Submission #392046

# Submission time Handle Problem Language Result Execution time Memory
392046 2021-04-20T10:29:49 Z A_D Paint (COI20_paint) C++14
0 / 100
45 ms 1092 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 fl(int u)
{
    if(u==l[u]){
        if(u==1)return u;
        if(a[u-1]!=a[u]){
            return u;
        }
        else{
            return l[u]=fl(u-1);
        }
    }
    return l[u]=fl(l[u]);
}
int fr(int u)
{
    if(u==r[u]){
        if(u==1)return u;
        if(a[u+1]!=a[u]){
            return u;
        }
        else{
            return r[u]=fr(u+1);
        }
    }
    return r[u]=fr(r[u]);
}
void solve()
{
    int n;
    cin>>n>>n;
    for(int i=1;i<=n;i++){
        l[i]=i;
        r[i]=i;
        scanf("%d",&a[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:65:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   65 | main()
      |      ^
paint.cpp: In function 'void solve()':
paint.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
paint.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
paint.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
paint.cpp:53:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   53 |         scanf("%d",&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 45 ms 1092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 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 -