Submission details
Task:Niitty
Sender:rottis
Submission time:2025-11-25 01:32:23 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:55:54: error: 'c_col' was not declared in this scope
   55 |                 solutions += (n - bottom) * (right - c_col + 1);
      |                                                      ^~~~~
input/code.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
input/code.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%s", buf);
      |         ~~~~~^~~~~~~~~~~

Code

#define to_bit(c) (1<<(c - 'A'))
#define bitmap uint32_t
 
#include <stdio.h>
#include <stdint.h>
 
int n;
bitmap found_flowers = 0;
bitmap board[500][500];
 
int main() {
    scanf("%d", &n);
 
    char buf[501];
    
    for (int i = 0; i < n; i++) {
        scanf("%s", buf);
        for (int j = 0; j < n; j++) {
            found_flowers = found_flowers | to_bit(buf[j]);
            board[i][j] = to_bit(buf[j]);
        }
    }
 
    long solutions = 0;
    
    bitmap columns[500];
    bitmap cols_bwise_ored;
    int right;
    int bottom;
    int iters_to_skip;
 
    for (int left = 0; left < n; left++) {
        for (int top = 0; top < n; top++) {
            right = n-1;
            bottom = top;
            for (int c_col = left; c_col <= right; c_col++) {
                columns[c_col] = board[c_col][top];
            }
            
            begin:
                cols_bwise_ored = 0;
                for (int c_col = left; c_col <= right; c_col++) {
                    cols_bwise_ored |= columns[c_col];
                    
                    if (cols_bwise_ored == found_flowers) {
                        iters_to_skip = right - c_col + 1;
                        goto valid;
                    }
                }
                goto invalid;
 
            
            valid:
                //std::cout << "valid!\n";
                solutions += (n - bottom) * (right - c_col + 1);
                right -= (right - c_col + 1);
                if (right < left) {
                    goto next;
                }
                goto begin;
            
            invalid:
                //std::cout << "invalid...\n";
                if (++bottom >= n) {
                    goto next;
                }
 
                for (int c_col = left; c_col <= right; c_col++) {
                    columns[c_col] |= board[c_col][bottom];
                }
                goto begin;
                
                //std::cout << std::endl;
            
            next:
            if (bottom == n && right == n-1) {
                goto next_column;
            }
            continue;
        }
        next_column: continue;
    }
 
    printf("%ld", solutions);
 
    return 0;
}