답안 #1055745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055745 2024-08-13T04:54:05 Z 김은성(#11066) Pizza Party (CCO24_day1problem2) C++17
0 / 12
263 ms 24808 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int inv[1000009], b[1000009], rev[1000009];
int ans[1000009];
int main(){
	int n, m, i, val;
	scanf("%d", &n, &m);
	for(i=1; i<=n; i++){
		scanf("%d", &val);
		inv[val] = i;
	}
	for(i=1; i<=n; i++){
		scanf("%d", &b[n+1-i]);
		b[n+1-i] = -inv[b[n+1-i]];
	}
	vector<int> vec;
	for(i=1; i<=n; i++){
		int idx = lower_bound(vec.begin(), vec.end(), b[i]) - vec.begin();
		if(idx == vec.size())
			vec.push_back(b[i]);
		else
			vec[idx] = b[i];
		ans[n+1-i] = idx;
		rev[-b[i]] = idx;
	}
	printf("%d\n", vec.size());
	for(i=1; i<=n; i++)
		printf("%d ", ans[i] + 1);
	printf("\n");
	for(i=1; i<=n; i++)
		printf("%d ", rev[i] + 1);
	printf("\n");
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:8: warning: too many arguments for format [-Wformat-extra-args]
    8 |  scanf("%d", &n, &m);
      |        ^~~~
Main.cpp:20:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   if(idx == vec.size())
      |      ~~~~^~~~~~~~~~~~~
Main.cpp:27:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   27 |  printf("%d\n", vec.size());
      |          ~^     ~~~~~~~~~~
      |           |             |
      |           int           std::vector<int>::size_type {aka long unsigned int}
      |          %ld
Main.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~
Main.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d", &val);
      |   ~~~~~^~~~~~~~~~~~
Main.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &b[n+1-i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 160 ms 12224 KB Expected EOLN
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Expected EOLN
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 263 ms 24808 KB Expected EOLN
2 Halted 0 ms 0 KB -