QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#363855#7940. Impossible NumbersmcpqndqWA 2ms3948kbC++171.8kb2024-03-24 04:22:042024-03-24 04:22:05

Judging History

你现在查看的是最新测评结果

  • [2024-03-24 04:22:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3948kb
  • [2024-03-24 04:22:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void place(array<int,12>& cts, set<string>& dest, string& built, int& lim){
	if(lim == 0) return;
	int tot = 0;
	rep(d,0,12)tot+=cts[d];
	rep(d,0,10){
		if(cts[d]+cts[10]==0) continue;
		if(d==0 && sz(built)==0) continue;
		int mode = 0;
		if(cts[d]>0){
			if(cts[11]>0) mode=2;
			else mode = 1;
		}
		if(mode==0) cts[10]--;
		else if(mode==2) cts[11]--;
		else cts[d]--;
		built.pb('0'+d);
		place(cts,dest,built, lim);
		built.pop_back();
		if(mode==0) cts[10]++;
		else if(mode==2) cts[11]++;
		else cts[d]++;
		if(lim==0) break;
	}
	if(tot==0){
		// cout<<"why <"<<built<<">"<<endl;
		dest.insert(built);
		lim--;
	}
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	int n,k;cin>>n>>k;
	vi cubes(n,0);rep(i,0,n)rep(j,0,6){
		int d;cin>>d;
		cubes[i]|=1<<d;
	}
	vi zs(1<<10,0);
	rep(fam,2,1<<10){
		rep(i,0,n) if(cubes[i]&fam) zs[fam]++;
	}
	vector<vector<array<int,12>>> steps(n+10);
	rep(fam,2,1<<10) {
		int req = max(__builtin_popcount(fam),zs[fam]+1);
		array<int,12> cts={0};
		int fir = -1;
		rep(i,0,10) if(fam&(1<<i)){
			if(fir==-1) fir = i;
			cts[i]++;
		}
		cts[11] += req - __builtin_popcount(fam);
		rep(r,req,n+10){
			steps[r].pb(cts);
			cts[10]++;
		}


	}

	rep(i,1,n+10){
		if(k==0) break;
		set<string> o;
		for(auto& cts : steps[i]){
			string s="";
			int lim = k;
			// cout<<"CALLL"<<endl;
			place(cts, o, s, lim);
			while(sz(o)>k) o.erase(prev(o.end()));
		}
		k-=sz(o);
		for(string s : o)cout<<s<<' ';
	}
	cout<<'\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3724kb

input:

2 3
1 8 7 0 6 2
1 2 5 4 9 3

output:

33 34 35 

result:

ok single line: '33 34 35 '

Test #2:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

1 10
1 5 2 2 6 4

output:

3 7 8 9 10 11 12 13 14 15 

result:

ok single line: '3 7 8 9 10 11 12 13 14 15 '

Test #3:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

4 10
1 5 7 1 2 4
0 1 5 8 9 4
3 5 2 2 7 8
6 1 7 0 2 2

output:

33 66 99 133 166 199 233 266 299 303 

result:

ok single line: '33 66 99 133 166 199 233 266 299 303 '

Test #4:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

5 10
5 9 4 8 3 3
1 1 9 2 8 9
6 3 3 0 2 1
2 6 0 3 6 4
3 6 4 2 9 4

output:

7 17 27 37 47 55 57 67 70 71 

result:

ok single line: '7 17 27 37 47 55 57 67 70 71 '

Test #5:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

5 10
8 7 1 4 8 9
2 5 0 1 0 1
9 5 5 3 9 7
6 0 0 2 3 1
1 0 0 4 9 3

output:

66 88 166 188 222 226 262 266 288 366 

result:

ok single line: '66 88 166 188 222 226 262 266 288 366 '

Test #6:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

5 10
6 8 7 7 0 0
0 5 1 9 4 1
5 9 6 9 5 4
0 4 6 9 1 6
2 8 7 4 4 0

output:

3 13 22 23 30 31 32 33 34 35 

result:

ok single line: '3 13 22 23 30 31 32 33 34 35 '

Test #7:

score: -100
Wrong Answer
time: 2ms
memory: 3936kb

input:

5 1000
0 4 1 3 9 6
9 6 2 1 8 6
5 3 0 7 7 3
0 2 8 0 8 4
2 4 1 2 9 7

output:

55 155 255 333 335 353 355 455 505 515 525 535 545 550 551 552 553 554 555 556 557 558 559 565 575 585 595 655 666 755 757 775 777 855 888 955 1055 1111 1116 1119 1155 1161 1169 1191 1196 1255 1333 1335 1353 1355 1455 1505 1515 1525 1535 1545 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1565 15...

result:

wrong answer 1st lines differ - expected: '55 155 255 333 335 353 355 455...0 10053 10055 10111 10116 10119', found: '55 155 255 333 335 353 355 455... 11193 11194 11195 11196 11197 '