Submission #1095015

# Submission time Handle Problem Language Result Execution time Memory
1095015 2024-10-01T07:20:25 Z alexander707070 Toys (CEOI18_toy) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
#define MAXN 2007
using namespace std;

int n;
vector<int> dels;

vector<int> sums[MAXN][2];
unordered_map<int,int> pos;
vector<int> res;
vector<int> ans;

unordered_map<int,int> li;
int tim;

void ff(int d,int mins){
	if(mins>d){
		sums[d][mins]={dels[d]-1};
		return;
	}

	if(!sums[d][mins].empty())return;

	ff(d,mins+1);
	sums[d][mins]=sums[d][mins+1];
	
	if(dels[d]%dels[mins]==0){
		int x=pos[dels[d]/dels[mins]];
		ff(x,mins);

		tim++;
		for(int i:sums[d][mins])li[i]=tim;

		for(int i:sums[x][mins]){
			if(li[i+dels[mins]-1]==tim)continue;
			li[i+dels[mins]-1]=tim;
			
			sums[d][mins].push_back(i+dels[mins]-1);
		}
	}
}

int main(){

	cin>>n;

	for(int i=1;i*i<=n;i++){
		if(n%i!=0)continue;

		dels.push_back(i);
		if(i!=n/i)dels.push_back(n/i);
	}

	sort(dels.begin(),dels.end());

	for(int i=0;i<dels.size();i++){
		pos[dels[i]]=i;
	}

	for(int mins=dels.size()-1;mins>=1;mins--){
		for(int d=0;d<dels.size();d++){

			if(mins>d){
				sums[d][mins%2]={dels[d]-1};
				continue;
			}

			sums[d][mins%2]=sums[d][1-mins%2];
			
			if(dels[d]%dels[mins]==0){
				int x=pos[dels[d]/dels[mins]];

				tim++;
				for(int i:sums[d][mins%2])li[i]=tim;

				for(int i:sums[x][mins%2]){
					if(li[i+dels[mins]-1]==tim)continue;
					li[i+dels[mins]-1]=tim;
					
					sums[d][mins%2].push_back(i+dels[mins]-1);
				}
			}	
		}
	}
	
	ans=sums[dels.size()-1][1];

	sort(ans.begin(),ans.end());

	cout<<ans.size()<<"\n";
	for(int i:ans){
		cout<<i<<" ";
	}
	cout<<"\n";

    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:56:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i=0;i<dels.size();i++){
      |              ~^~~~~~~~~~~~
toy.cpp:61:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   for(int d=0;d<dels.size();d++){
      |               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -