답안 #277953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
277953 2020-08-21T08:13:44 Z Revo7 Bubble Sort 2 (JOI18_bubblesort2) C++14
60 / 100
945 ms 11156 KB
#include "bubblesort2.h"
#include<bits/stdc++.h>
#define pb push_back

using namespace std;

vector<int> countScans(vector<int> a,vector<int> pos,vector<int> v){
    if(a.size()<=8000){
         set<pair<int,int>>s;
    for(int i=0;i<a.size();i++){
        s.insert({a[i],i});
    }
    vector<int>ans;
    for(int i=0;i<pos.size();i++){
        int mx=0;
        s.erase({a[pos[i]],pos[i]});
        a[pos[i]]=v[i];
        s.insert({a[pos[i]],pos[i]});
        int cur=0;
        for(auto x:s){
            mx=max(mx,x.second-cur);
            cur++;
        }
        ans.pb(mx);
        //cout<<ans.back()<<endl;
    }
	return ans;
    }
    set<int>s[111];

    for(int i=0;i<a.size();i++){
        s[a[i]].insert(i);
    }
    vector<int>ans;

    for(int i=0;i<pos.size();i++){
        //cout<<i<<endl;
        int mx=0,id=pos[i],newval=v[i];
        s[a[id]].erase(id);
        a[id]=newval;
        s[newval].insert(id);
        int cur=0;
        for(int j=1;j<=100;j++){
            cur+=s[j].size();
            if(s[j].size())
            mx=max(mx,*s[j].rbegin()-cur+1);
        }
        ans.pb(mx);
    }
	return ans;
}
/*
4 2
1 2 3 4
0 3
2 1
*/

Compilation message

bubblesort2.cpp: In function 'std::vector<int> countScans(std::vector<int>, std::vector<int>, std::vector<int>)':
bubblesort2.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
bubblesort2.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0;i<pos.size();i++){
      |                 ~^~~~~~~~~~~
bubblesort2.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
bubblesort2.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<pos.size();i++){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 16 ms 384 KB Output is correct
3 Correct 92 ms 512 KB Output is correct
4 Correct 49 ms 512 KB Output is correct
5 Correct 98 ms 512 KB Output is correct
6 Correct 35 ms 512 KB Output is correct
7 Correct 46 ms 512 KB Output is correct
8 Correct 42 ms 508 KB Output is correct
9 Correct 49 ms 512 KB Output is correct
10 Correct 38 ms 512 KB Output is correct
11 Correct 41 ms 560 KB Output is correct
12 Correct 38 ms 512 KB Output is correct
13 Correct 39 ms 552 KB Output is correct
14 Correct 46 ms 512 KB Output is correct
15 Correct 47 ms 512 KB Output is correct
16 Correct 48 ms 512 KB Output is correct
17 Correct 45 ms 512 KB Output is correct
18 Correct 46 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 16 ms 384 KB Output is correct
3 Correct 92 ms 512 KB Output is correct
4 Correct 49 ms 512 KB Output is correct
5 Correct 98 ms 512 KB Output is correct
6 Correct 35 ms 512 KB Output is correct
7 Correct 46 ms 512 KB Output is correct
8 Correct 42 ms 508 KB Output is correct
9 Correct 49 ms 512 KB Output is correct
10 Correct 38 ms 512 KB Output is correct
11 Correct 41 ms 560 KB Output is correct
12 Correct 38 ms 512 KB Output is correct
13 Correct 39 ms 552 KB Output is correct
14 Correct 46 ms 512 KB Output is correct
15 Correct 47 ms 512 KB Output is correct
16 Correct 48 ms 512 KB Output is correct
17 Correct 45 ms 512 KB Output is correct
18 Correct 46 ms 512 KB Output is correct
19 Correct 891 ms 1176 KB Output is correct
20 Correct 945 ms 1280 KB Output is correct
21 Correct 935 ms 1144 KB Output is correct
22 Correct 827 ms 1144 KB Output is correct
23 Correct 653 ms 1204 KB Output is correct
24 Correct 793 ms 1144 KB Output is correct
25 Correct 740 ms 1140 KB Output is correct
26 Correct 758 ms 1108 KB Output is correct
27 Correct 782 ms 1144 KB Output is correct
28 Correct 704 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1920 KB Output is correct
2 Correct 74 ms 3192 KB Output is correct
3 Correct 92 ms 4472 KB Output is correct
4 Correct 87 ms 4472 KB Output is correct
5 Correct 115 ms 4500 KB Output is correct
6 Correct 88 ms 4472 KB Output is correct
7 Correct 122 ms 4472 KB Output is correct
8 Correct 90 ms 4472 KB Output is correct
9 Correct 88 ms 4472 KB Output is correct
10 Correct 73 ms 4472 KB Output is correct
11 Correct 72 ms 4476 KB Output is correct
12 Correct 76 ms 4532 KB Output is correct
13 Correct 84 ms 4472 KB Output is correct
14 Correct 72 ms 4472 KB Output is correct
15 Correct 71 ms 4472 KB Output is correct
16 Correct 72 ms 4472 KB Output is correct
17 Correct 62 ms 4472 KB Output is correct
18 Correct 60 ms 4480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 16 ms 384 KB Output is correct
3 Correct 92 ms 512 KB Output is correct
4 Correct 49 ms 512 KB Output is correct
5 Correct 98 ms 512 KB Output is correct
6 Correct 35 ms 512 KB Output is correct
7 Correct 46 ms 512 KB Output is correct
8 Correct 42 ms 508 KB Output is correct
9 Correct 49 ms 512 KB Output is correct
10 Correct 38 ms 512 KB Output is correct
11 Correct 41 ms 560 KB Output is correct
12 Correct 38 ms 512 KB Output is correct
13 Correct 39 ms 552 KB Output is correct
14 Correct 46 ms 512 KB Output is correct
15 Correct 47 ms 512 KB Output is correct
16 Correct 48 ms 512 KB Output is correct
17 Correct 45 ms 512 KB Output is correct
18 Correct 46 ms 512 KB Output is correct
19 Correct 891 ms 1176 KB Output is correct
20 Correct 945 ms 1280 KB Output is correct
21 Correct 935 ms 1144 KB Output is correct
22 Correct 827 ms 1144 KB Output is correct
23 Correct 653 ms 1204 KB Output is correct
24 Correct 793 ms 1144 KB Output is correct
25 Correct 740 ms 1140 KB Output is correct
26 Correct 758 ms 1108 KB Output is correct
27 Correct 782 ms 1144 KB Output is correct
28 Correct 704 ms 1144 KB Output is correct
29 Correct 28 ms 1920 KB Output is correct
30 Correct 74 ms 3192 KB Output is correct
31 Correct 92 ms 4472 KB Output is correct
32 Correct 87 ms 4472 KB Output is correct
33 Correct 115 ms 4500 KB Output is correct
34 Correct 88 ms 4472 KB Output is correct
35 Correct 122 ms 4472 KB Output is correct
36 Correct 90 ms 4472 KB Output is correct
37 Correct 88 ms 4472 KB Output is correct
38 Correct 73 ms 4472 KB Output is correct
39 Correct 72 ms 4476 KB Output is correct
40 Correct 76 ms 4532 KB Output is correct
41 Correct 84 ms 4472 KB Output is correct
42 Correct 72 ms 4472 KB Output is correct
43 Correct 71 ms 4472 KB Output is correct
44 Correct 72 ms 4472 KB Output is correct
45 Correct 62 ms 4472 KB Output is correct
46 Correct 60 ms 4480 KB Output is correct
47 Runtime error 98 ms 11156 KB Execution killed with signal 11
48 Halted 0 ms 0 KB -