QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#879877#5414. Stop, Yesterday Please No MoreThe_8th_HorcruxCompile Error//C++231.5kb2025-02-02 17:04:592025-02-02 17:05:00

Judging History

This is the latest submission verdict.

  • [2025-02-02 17:05:00]
  • Judged
  • [2025-02-02 17:04:59]
  • Submitted

answer

#define rep(a,b,c) for(int a=b;a<=c;a++)
const int N = 2e3 + 10;
int f[N][N];
string s;
int n, m, k;
 
void solve(){
    cin >> n >> m >> k >> s;
    rep(i, 0, 2 * n + 2)
        rep(j, 0, 2 * m + 2)
            f[i][j] = 0;
    int len = sz(s);
    s = " " + s;
 
    int U, D, L, R;
    U = 1, D = n, L = 1, R = m;
    for(int i = 1, u = 1, d = n, l = 1, r = m; i <= len; i ++){
        if(s[i] == 'U') u --, d --;
        else if(s[i] == 'R') l ++, r ++;
        else if(s[i] == 'L') l --, r --;
        else u ++, d ++;
        U = max(U, u), D = min(D, d), R = min(R, r), L = max(L, l);
    }
 
    if(U > D || R < L){
        if(k == 0) cout << n * m << endl;
        else cout << 0 << endl;
        return;
    }
 
    k = (D - U + 1) * (R - L + 1) - k;    
    if(k < 0){
        cout << 0 << endl;
        return;
    }
 
    for(int i = 1, x = n + 1, y = m + 1; i <= len; i ++){
        if(s[i] == 'U') x --;
        else if(s[i] == 'R') y ++;
        else if(s[i] == 'L') y --;
        else x ++;
        f[x][y] = 1;
    }
    f[n + 1][m + 1] = 1;
    rep(i,1,2 * n + 1)
        rep(j,1,2 * m + 1)
            f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
 
    int ans = 0;
    rep(i,1,n)
        rep(j,1,m){
            int x = n + 1 - i, y = m + 1 - j;
            int num = f[x + D][y + R] - f[U + x - 1][R + y] - f[D + x][L + y - 1] + f[U + x - 1][L + y - 1];
 
            if(num == k)
                ans ++;
        }
 
    cout << ans << endl;
}

Details

answer.code:4:1: error: ‘string’ does not name a type
    4 | string s;
      | ^~~~~~
answer.code: In function ‘void solve()’:
answer.code:8:5: error: ‘cin’ was not declared in this scope
    8 |     cin >> n >> m >> k >> s;
      |     ^~~
answer.code:8:27: error: ‘s’ was not declared in this scope
    8 |     cin >> n >> m >> k >> s;
      |                           ^
answer.code:12:15: error: ‘sz’ was not declared in this scope
   12 |     int len = sz(s);
      |               ^~
answer.code:22:13: error: ‘max’ was not declared in this scope
   22 |         U = max(U, u), D = min(D, d), R = min(R, r), L = max(L, l);
      |             ^~~
answer.code:22:28: error: ‘min’ was not declared in this scope
   22 |         U = max(U, u), D = min(D, d), R = min(R, r), L = max(L, l);
      |                            ^~~
answer.code:26:20: error: ‘cout’ was not declared in this scope
   26 |         if(k == 0) cout << n * m << endl;
      |                    ^~~~
answer.code:26:37: error: ‘endl’ was not declared in this scope
   26 |         if(k == 0) cout << n * m << endl;
      |                                     ^~~~
answer.code:27:14: error: ‘cout’ was not declared in this scope
   27 |         else cout << 0 << endl;
      |              ^~~~
answer.code:27:27: error: ‘endl’ was not declared in this scope
   27 |         else cout << 0 << endl;
      |                           ^~~~
answer.code:33:9: error: ‘cout’ was not declared in this scope
   33 |         cout << 0 << endl;
      |         ^~~~
answer.code:33:22: error: ‘endl’ was not declared in this scope
   33 |         cout << 0 << endl;
      |                      ^~~~
answer.code:59:5: error: ‘cout’ was not declared in this scope
   59 |     cout << ans << endl;
      |     ^~~~
answer.code:59:20: error: ‘endl’ was not declared in this scope
   59 |     cout << ans << endl;
      |                    ^~~~