Submission #1055785

# Submission time Handle Problem Language Result Execution time Memory
1055785 2024-08-13T05:25:58 Z 변재우(#11070) Pizza Party (CCO24_day1problem2) C++17
0 / 12
321 ms 28752 KB
#include <bits/stdc++.h>
using namespace std;

const int Nmax=1000010;
int N, K, A[Nmax], V[Nmax], X[Nmax], Y[Nmax], I[Nmax];
set<pair<int, int>> S;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N;
    for(int i=1; i<=N; i++) {
        int x; cin>>x, V[x]=i;
    }
    for(int i=1; i<=N; i++) cin>>A[i], A[i]=V[A[i]];
    for(int i=1; i<=N; i++) I[A[i]]=i;
    for(int i=1; i<=N; i++) if(A[i]==A[i-1]) {
        cout<<-1; return 0;
    }
    for(int i=1; i<=N; i++) {
        auto p=S.lower_bound(make_pair(A[i], 0));
        if(p==S.end()) X[i]=++K, S.insert({A[i], K});
        else {
            X[i]=(*p).second;
            S.erase(p), S.insert({A[i], X[i]});
        }
        Y[A[i]]=X[i];
    }
    cout<<K<<"\n";
    for(int i=1; i<=N; i++) cout<<X[i]<<" "; cout<<"\n";
    for(int i=1; i<=N; i++) cout<<Y[i]<<" "; cout<<"\n";
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:29:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   29 |     for(int i=1; i<=N; i++) cout<<X[i]<<" "; cout<<"\n";
      |     ^~~
Main.cpp:29:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   29 |     for(int i=1; i<=N; i++) cout<<X[i]<<" "; cout<<"\n";
      |                                              ^~~~
Main.cpp:30:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   30 |     for(int i=1; i<=N; i++) cout<<Y[i]<<" "; cout<<"\n";
      |     ^~~
Main.cpp:30:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   30 |     for(int i=1; i<=N; i++) cout<<Y[i]<<" "; cout<<"\n";
      |                                              ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 4176 KB jury uses fewer stacks: jans = 2, pans = 1061109567
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 321 ms 28752 KB Expected EOLN
2 Halted 0 ms 0 KB -