답안 #908149

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
908149 2024-01-16T08:39:12 Z tosivanmak 곤돌라 (IOI14_gondola) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll negmod(ll num, ll n){
    return ((num%n)+n)%n;
}
ll n,arr[100005];
bool ck(){
    ll cnt=0;
    map<ll,ll>mp;
        for(int i=1;i<=n;i++){
            if(arr[i]>n){
                cnt++;
            }
            mp[arr[i]]++;
            if(mp[arr[i]]>=2){
                return 0;
            }
        }
        if(cnt==n){
            return 1;
        }
        ll first;
        for(int i=1;i<=n;i++){
            if(arr[i]<=n){
                first=i;
                break;
            }
        }
        ll con[n+5];
        ll need=arr[first];
        for(int i=1;i<=n;i++){
           ll lol= negmod(i-first+need,n);
           if(!lol){lol=n;}
           con[i]=lol;
        }
        bool ok=true;
        for(int i=1;i<=n;i++){
            if(arr[i]<=n&&arr[i]!=con[i]){
                ok=0;
            }
        }
        if(ok){
            return 1;
        }
        else{
            return 0;
        }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll subtask;
    cin>>subtask;
    if(subtask<=3){
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
       if(ck()){
           cout<<"1\n";
       }
       else{
           cout<<"0\n";
       }
    }
    else if(subtask<=6){
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>arr[i];
        }
        set<pair<ll,ll> >st;
        ll recon[n+5];
        ll cnt=0;
        for(int i=1;i<=n;i++){
            cnt+=(arr[i]>n);
        }
        if(cnt==n){
            for(int i=1;i<=n;i++){
                recon[i]=i;
            }
        }
        else{
            ll saga;
            for(int i=1;i<=n;i++){
                if(arr[i]<=n){
                    saga=i;
                    break;
                }
            }
             ll need=arr[saga];
             for(int i=1;i<=n;i++){
                ll lol= negmod(i-saga+need,n);
                if(!lol)lol=n;
                recon[i]=lol;
            }
        }
        for(int i=1;i<=n;i++){
            st.insert({arr[i],i});
        }
        st.insert({300000,1});
        ll last=n;
        vector<ll>seq;
        while(1){
           pair<ll,ll>bruh=*st.lower_bound({last+1,0});
           if(bruh.first==300000){
               break;
           }
           seq.push_back(recon[bruh.second]);
           for(int i=last+2;i<=bruh.first;i++){
               seq.push_back(i-1);
           }
           last=bruh.first;
        }
        cout<<seq.size()<<'\n';
        for(auto& u: seq){
            cout<<u<<"\n";
        }
    }
}

Compilation message

gondola.cpp: In function 'bool ck()':
gondola.cpp:32:12: warning: 'first' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |         ll need=arr[first];
      |            ^~~~
gondola.cpp: In function 'int main()':
gondola.cpp:92:17: warning: 'saga' may be used uninitialized in this function [-Wmaybe-uninitialized]
   92 |              ll need=arr[saga];
      |                 ^~~~
/usr/bin/ld: /tmp/cctKPyYg.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccAPJlDf.o:gondola.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cctKPyYg.o: in function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
/usr/bin/ld: grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status