제출 #224811

#제출 시각아이디문제언어결과실행 시간메모리
224811BruteforcemanBubble Sort 2 (JOI18_bubblesort2)C++11
38 / 100
5045 ms1280 KiB
#include "bits/stdc++.h"
#include "bubblesort2.h"
using namespace std;

int solve(vector <int> &A) {
    vector <int> cmp (A.size()), pos (A.size());
    for(int i = 0; i < A.size(); i++) cmp[i] = i;
    sort(cmp.begin(), cmp.end(), [&] (int i, int j) { return A[i] < A[j]; });
    for(int i = 0; i < A.size(); i++) pos[cmp[i]] = i;
    int ans = 0;
    for(int i = 0; i < A.size(); i++) {
        ans = max(ans, i - pos[i]);
    }
    return ans;
}

std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
    vector <int> answer (X.size());
    for(int i = 0; i < X.size(); i++) {
        A[X[i]] = V[i];
        answer[i] = solve(A);
    }
	return answer;
}

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

bubblesort2.cpp: In function 'int solve(std::vector<int>&)':
bubblesort2.cpp:7:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) cmp[i] = i;
                    ~~^~~~~~~~~~
bubblesort2.cpp:9:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) pos[cmp[i]] = i;
                    ~~^~~~~~~~~~
bubblesort2.cpp:11:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < A.size(); i++) {
                    ~~^~~~~~~~~~
bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:19:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < X.size(); i++) {
                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...