QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#526504#8768. Arrested DevelopmentOneWan#Compile Error//C++234.0kb2024-08-21 16:49:262024-08-21 16:49:26

Judging History

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

  • [2024-08-21 16:49:26]
  • 评测
  • [2024-08-21 16:49:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long; 
#define len 50
int ss[41][41][401][2501];  //0 pre 1 now
int pre[41][41][401][2501];
int idx=0;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s; 
    s=" "+s;
    ss[0][0][0][0]=++idx;
    for (int i = 1; i <= n; i++) {  
        if(s[i] != 'N' && s[i] != 'A' && s[i] != 'C' && s[i] != '?') {
            for(int x=0;x<=40;x++){
            	for(int y=0;y<=400;y++){
            		for(int cnt=0;cnt<=2500;cnt++){ 
	            		if(ss[i-1][x][y][cnt]){
	            			ss[i][x][y][cnt]=++idx;
	            			pre[i][x][y][cnt]=ss[i-1][x][y][cnt];
	            		} 
            		}
            	}
            }
            continue;
        } 
        if(s[i] == 'N') { 
            for(int x=0;x<=40;x++){
            	for(int y=0;y<=400;y++){
            		for(int cnt=0;cnt<=2500;cnt++){
            			if(x + 1 <= 40 && ss[i-1][x][y][cnt]&&ss[i][x+1][y][cnt]==0){
            				ss[i][x+1][y][cnt]=++idx;
            				pre[i][x+1][y][cnt]=ss[i-1][x][y][cnt];
            			}
            		}
            	}
            }
        }
        if(s[i] == 'A') { 
             for(int x=0;x<=40;x++){
            	for(int y=0;y<=400;y++){
            		for(int cnt=0;cnt<=2500;cnt++){
            			if(x+y <= 40 && ss[i-1][x][y][cnt]&&ss[i][x][y+x][cnt]==0){
            				ss[i][x][y+x][cnt]=++idx;
            				pre[i][x][y+x][cnt]=ss[i-1][x][y][cnt];
            			}
            		}
            	}
            }
        }
        if(s[i] == 'C') { 
              for(int x=0;x<=40;x++){
            	for(int y=0;y<=400;y++){
            		for(int cnt=0;cnt<=2500;cnt++){
            			if(!ss[i-1][x][y][cnt])continue;
            			if(cnt+y<=k&&ss[i][x][y][cnt+y]==0){
            				ss[i][x][y][cnt+y]=++idx;
            				pre[i][x][y][cnt+y]=ss[i-1][x][y][cnt];
            			}
            		}
            	}
            }
        }
        if(s[i] == '?') { 
            for(int x=0;x<=40;x++){
            	for(int y=0;y<=400;y++){
            		for(int cnt=0;cnt<=2500;cnt++){
            			if(!ss[i-1][x][y][cnt])continue;
            			if(ss[i-1][x][y][cnt]){
	            			ss[i][x][y][cnt]=++idx;
	            			pre[i][x][y][cnt]=ss[i-1][x][y][cnt];
	            		} 
            			if(x + 1 <= 40 && ss[i-1][x][y][cnt]&&ss[i][x+1][y][cnt]==0){
            				ss[i][x+1][y][cnt]=++idx;
            				pre[i][x+1][y][cnt]=ss[i-1][x][y][cnt];
            			}
            			if(x + y <= 40 && ss[i-1][x][y][cnt]&&ss[i][x][y+x][cnt]==0){
            				ss[i][x][y+x][cnt]=++idx;
            				pre[i][x][y+x][cnt]=ss[i-1][x][y][cnt];
            			}
            			if(cnt+y<=k&&ss[i][x][y][cnt+y]==0){
            				ss[i][x][y][cnt+y]=++idx;
            				pre[i][x][y][cnt+y]=ss[i-1][x][y][cnt];
            			}
            		}
            	}
            }
          
        } 
    }  
    int i = n, x = -1, y = -1, cnt = k;
	for (int x1 = 0; x1 <= 40; x1++)
		for (int y1 = 0; y1 <= 400; y1++) {
			if(ss[n][x1][y1][k]) x = x1, y = y1;
		}
		
    if((x==-1)&&(y==-1)) {
    	cout << "-1\n";
    	return 0;
    }
    
    vector<char>ans;
    
    while(1) {
    	if(i==0)break;
    	if(pre[i][x][y][cnt] == ss[i - 1][x][y][cnt]) {
    		i--;
    		ans.push_back('B');
    		continue; 
    	}
    	if(x - 1 >= 0 && pre[i][x][y][cnt] == ss[i - 1][x - 1][y][cnt]) {
    		x = x - 1;
    		i--;
    		ans.push_back('N');
    		continue; 
    	}
    	if(y - x >= 0 && pre[i][x][y][cnt] == ss[i - 1][x][y - x][cnt]) {
    		y -= x;
    		i--;
    		ans.push_back('A');
    		continue; 
    	}
    	if(cnt - y >= 0 && pre[i][x][y][cnt] == ss[i - 1][x][y][cnt - y]) {
    		cnt -= y;
    		i--;
    		ans.push_back('C');
    		continue; 
    	}
    }
    
    for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
    return 0;
}

Details

/tmp/ccOwVgF4.o: in function `main':
answer.code:(.text.startup+0x1b1): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x1c7): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x2f5): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x611): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x725): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x7c8): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x88b): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x8e1): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x91b): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
answer.code:(.text.startup+0x959): relocation truncated to fit: R_X86_64_PC32 against symbol `ss' defined in .bss section in /tmp/ccOwVgF4.o
collect2: error: ld returned 1 exit status