Submission #393462

# Submission time Handle Problem Language Result Execution time Memory
393462 2021-04-23T14:01:17 Z A_D Paint (COI20_paint) C++14
9 / 100
134 ms 8916 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=1e6+100;
int a[N];
int l[N];
int r[N];
void compine(int a,int b)
{
    r[a]=r[b];
    l[b]=l[a];
}
int fl(int u)
{
    if(u==l[u])return l[u];
    return l[u]=fl(l[u]);
}
int fr(int u)
{
    if(u==r[u])return r[u];
    return r[u]=fr(r[u]);
}
void solve()
{
    int n;
    cin>>n>>n;
    for(int i=1;i<=n;i++)cin>>a[i],l[i]=i,r[i]=i;
    for(int i=1;i<n;i++){
        if(a[i]==a[i+1]){
            compine(i,i+1);
        }
    }
    int q;
    cin>>q;
    while(q--){
        int i,c;
        scanf("%lld",&i);
        scanf("%lld",&i);
        scanf("%lld",&c);
        int le=fl(i);
        int ri=fr(i);
        a[le]=c;
        a[ri]=c;
        if(le!=1){
            if(a[le]==a[le-1]){
                compine(le-1,le);
            }
        }
        if(ri!=n){
            if(a[ri]==a[ri+1]){
                compine(ri,ri+1);
            }
        }
    }
    for(int i=1;i<=n;i++){
        int x=fl(i);
        x=a[x];
        cout<<x<<" ";
    }
}

main()
{
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    int t=1;
//    cin>>t;
    while(t--)solve();
}

Compilation message

paint.cpp:66:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   66 | main()
      |      ^
paint.cpp: In function 'void solve()':
paint.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         scanf("%lld",&i);
      |         ~~~~~^~~~~~~~~~~
paint.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |         scanf("%lld",&i);
      |         ~~~~~^~~~~~~~~~~
paint.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |         scanf("%lld",&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 Correct 53 ms 2628 KB Output is correct
2 Correct 71 ms 3568 KB Output is correct
3 Correct 134 ms 8916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 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 -