Submission #392058

# Submission time Handle Problem Language Result Execution time Memory
392058 2021-04-20T10:56:21 Z A_D Paint (COI20_paint) C++14
Compilation error
0 ms 0 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]||r[u-1]!=u-1){
            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==n)return u;
        if(a[u+1]!=a[u]||l[u+1]!=u+1){
            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]);
    }
    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: In function 'int fr(int)':
paint.cpp:28:15: error: 'n' was not declared in this scope
   28 |         if(u==n)return u;
      |               ^
paint.cpp: At global scope:
paint.cpp:69:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | 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:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   55 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
paint.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   56 |         scanf("%d",&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",&c);
      |         ~~~~~^~~~~~~~~