QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#658127#6300. Best Carry Player 2Fluoresce#Compile Error//C++201.7kb2024-10-19 16:12:462024-10-19 16:12:47

Judging History

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

  • [2024-10-19 16:12:47]
  • 评测
  • [2024-10-19 16:12:46]
  • 提交

answer

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
typedef long long ll;
typedef long double ld;
#define debug(a) cout<<a<<'\n'
#define Pll pair<ll,ll>
#define PII pair<int,int>
#define ft first
#define sd second
#define vec vector
#define pushk push_back
#define ump unordered_map
#define pl p<<1
#define pr p<<1|1
using namespace std;
const int N = 15 + 10, M = 1e4 + 10, mod = 1e9 + 7;
const ll inf = 1e18;
const ld eps = 1e-13;
int mov[4][2] = { {0,1},{1,0},{-1,0},{0,-1} }, dx, dy, _ = 1, __ = 1;
void bout(bool f) {
	if (f)cout << "Yes\n";
	else cout << "No\n";
}
ll n, m, k;
ull p[25],dp[25][2],pre[25][2];

void ini() {
	p[0]=1;
	for(int i=1;i<=19;++i)p[i]=10*p[i-1];
}
void solve() {
	string s;
	cin>>s>>k;
	reverse(s.begin(),s.end());
	memset(dp,0x3f,sizeof dp);
	dp[0][0]=0;
	int x,y,z;
	for(int i=0;i<k;++i){
		memcpy(pre,dp,sizeof dp);
		memset(dp,0x3f,sizeof dp);
		if(i<s.length())x=s[i]-'0';
		else x=0;
		if(x==9){
			for(int j=1;j<=i+1;++j){
				dp[j][0]=pre[j][0];
				dp[j][1]=min(pre[j-1][0]+p[i],pre[j-1][1]);
			}
		}else{
			for(int j=1;j<=i+1;++j){
				dp[j][0]=min(pre[j][0],pre[j][1]);
				dp[j][1]=min(pre[j-1][0]+(10-x)*p[i],pre[j-1][1]+(9-x)*p[i]);
			}
		}
		dp[0][0]=0;
	}
	if(!k)cout<<1<<'\n';
	else cout<<min(dp[k][0],dp[k][1])<<'\n';
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	streambuf* cinbackup = cin.rdbuf(), * coutbackup = cout.rdbuf();
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	cin.rdbuf(fin.rdbuf());
	cout.rdbuf(fout.rdbuf());
#endif
	cin >> _;
	__ = _;
	ini();
	while (_--) {
		solve();
	}
	return 0;
}

詳細信息

answer.code:26:1: error: ‘ull’ does not name a type; did you mean ‘ll’?
   26 | ull p[25],dp[25][2],pre[25][2];
      | ^~~
      | ll
answer.code: In function ‘void ini()’:
answer.code:29:9: error: ‘p’ was not declared in this scope
   29 |         p[0]=1;
      |         ^
answer.code: In function ‘void solve()’:
answer.code:36:16: error: ‘dp’ was not declared in this scope; did you mean ‘dy’?
   36 |         memset(dp,0x3f,sizeof dp);
      |                ^~
      |                dy
answer.code:40:24: error: ‘pre’ was not declared in this scope; did you mean ‘pr’?
   40 |                 memcpy(pre,dp,sizeof dp);
      |                        ^~~
      |                        pr
answer.code:47:58: error: ‘p’ was not declared in this scope
   47 |                                 dp[j][1]=min(pre[j-1][0]+p[i],pre[j-1][1]);
      |                                                          ^
answer.code:52:65: error: ‘p’ was not declared in this scope
   52 |                                 dp[j][1]=min(pre[j-1][0]+(10-x)*p[i],pre[j-1][1]+(9-x)*p[i]);
      |                                                                 ^