제출 #229335

#제출 시각아이디문제언어결과실행 시간메모리
229335osaaateiasavtnl곤돌라 (IOI14_gondola)C++14
20 / 100
44 ms4732 KiB
#include<bits/stdc++.h>
using namespace std;

#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

#include "gondola.h"

signed valid(signed n, signed a[])
{
    set <int> ms;
    for (int i = 0; i < n; ++i)
        ms.insert(a[i]);
    if (ms.size() < n)
        return 0;

    int pos = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= n) {
            pos = i;
            break;
        }
    }   

    if (pos == -1) 
        return 1;
    else {
        for (int sh = 0; sh < n; ++sh) {
            int i = (pos + sh) % n;
            int val = a[pos] + sh;
            if (val > n)
                val -= n;
            if (a[i] <= n && a[i] != val)
                return 0;
        }
        return 1;
    }   

}

//----------------------

signed replacement(signed n, signed a[], signed ans[])
{

    int pos = -1, S;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= n) {
            pos = i;
            pos = a[i];
            break;
        }
    }   
    
    if (pos == -1) {
        pos = 0;
        S = 1;
    }

    vector <ii> ar;
    for (int sh = 0; sh < n; ++sh) {
        int i = (pos + sh) % n;
        int val = S + sh;
        if (val > n)
            val -= n;
        if (a[i] > n) {
            ar.app(mp(a[i], val));
        }   
    }
    sort(all(ar));
    int ptr = 0;
    int xp = n + 1;
    for (auto e : ar) {
        int cur = e.s;
        while (xp <= e.f) {
            //cout << cur << "->" << xp << endl;
            ans[ptr++] = cur;
            cur = xp++;
        }                           
    }   
    return ptr;
}

//----------------------

signed countReplacement(signed n, signed inputSeq[])
{
  return -3;
}

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (ms.size() < n)
         ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...