제출 #1119715

#제출 시각아이디문제언어결과실행 시간메모리
1119715vjudge1Toys (CEOI18_toy)C++17
79 / 100
5034 ms130372 KiB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll int
#define F first
#define S second
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;
const int N = 500001;

using namespace std;
using namespace __gnu_pbds;

ll n, a;
map <vector<ll>, ll> mp;
set <ll> ans;

void rec (vector <ll> v, ll sum){
	mp[v]++;
//	for (auto i: v){
//		cout << i << ' ';
//	}
//	cout << '\n';
	ans.insert (sum - v.size());
	vector <ll> q;
	for (int i = 0; i < v.size(); i++){
		for (int y = 2; y <= sqrt (v[i]); y++){
			if (v[i] % y == 0){
				q.clear();
				for (int j = 0; j < v.size(); j++){
					if (i == j){
						continue;
					}
					q.pb (v[j]);
				}
				q.pb(y);
				q.pb(v[i] / y);
				sort (all (q));
				if (mp[q] == 0)rec (q, sum - v[i] + y + v[i] / y);
			}
		}
	}
}

signed main (){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	rec ({n}, n);
	cout << ans.size() << '\n';
	for (auto i: ans){
		cout << i << ' ';
	}
}

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

toy.cpp: In function 'void rec(std::vector<int>, int)':
toy.cpp:38:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for (int i = 0; i < v.size(); i++){
      |                  ~~^~~~~~~~~~
toy.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int j = 0; j < v.size(); j++){
      |                     ~~^~~~~~~~~~
#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...