Submission #1107997

# Submission time Handle Problem Language Result Execution time Memory
1107997 2024-11-02T14:30:55 Z kuka_123 Red-blue table (IZhO19_stones) C++14
Compilation error
0 ms 0 KB
                              /*Bismillahir Rahmanir Raheem*/
#include <bits/stdc++.h>
  
using namespace std;

#define kuka ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);
#define pb push_back
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define FOR(n) for(int i = 0; i < n; i++)
#define ff(x, y) for( int y = 0; y < x; y++)
#define fff(x, y) for( int y = x; y <= 0; y--)
#define F first
#define S second
#define int long long  

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll INF = LLONG_MAX;
const int inf = INT_MAX;
const double PI = acos(-1);
const int N = 1002;
const int MOD = 1e9 ;	 

char a[N][N];
int col[N];

void oyan(){
	int n, m, ans = 0;
    cin >> n >> m;
    if (n > m) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                a[i][j] = '+';
            }
            col[i] = (m - 1) / 2;
        }
	    ans = n;
	    for (int j = 1; j <= m; ++j) {
		    int cnt = 0;
		    if (j % 2 == 0) {
		        for (int i = 1; i <= n; ++i) {
		            if (cnt > n / 2) {
		                ans++;cnt = 0;
		                break;
		            }
		            if (col[i] != 0) {
		                col[i]--;
		                a[i][j] = '-';
		                cnt++;
		            }
		        }
		    } else {
		        for (int i = n; i >= 1; --i) {
		            if (cnt > n / 2) {
		                ans++;cnt = 0;
		                break;
		            }
		            if (col[i] != 0) {
		                col[i]--;
		                a[i][j] = '-';
		                cnt++;
		            }
		        }
		    }
		    if (cnt > n / 2) {
	           ans++;
		    }
		}
    }  else if(n < m){
    	for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                a[i][j] = '-';
                col[j] = (n - 1) / 2;
            }
        }
	    ans = m;
	    for (int j = 1; j <= n; ++j) {
		    int cnt = 0;
		    if (j % 2 == 0) {
		        for (int i = 1; i <= m; ++i) {
		            if (cnt > m / 2) {
		                ans++;cnt = 0;
		                break;
		            }
		            if (col[i] != 0) {
		                col[i]--;
		                a[j][i] = '+';
		                cnt++;
		            }
		        }
		    } else {
		        for (int i = m; i >= 1; --i) {
		            if (cnt > m / 2) {
		                ans++;cnt = 0;
		                break;
		            }
		            if (col[i] != 0) {
		                col[i]--;
		                a[j][i] = '+';
		                cnt++;
		            }
		        }
		    }
		    if (cnt > m / 2) {
		    	ans++;
		    }
		}
	}else{
		for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                a[i][j] = '-';
                col[j] = (n - 1) / 2;
            }
        }
        if (j % 2 == 0) {
		    for (int i = 1; i <= m; ++i) {
		       if (cnt > m / 2) {
		            ans++;cnt = 0;
		            break;
		        }
		        if (col[i] != 0) {
		            col[i]--;
	                a[j][i] = '+';
	                cnt++;
	            }
	        }
	    } else {
	        for (int i = m; i >= 1; --i) {
	            if (cnt > m / 2) {
	                ans++;cnt = 0;
	                break;
	            }
	            if (col[i] != 0) {
	                col[i]--;
	                a[j][i] = '+';
	                cnt++;
	            }
	        }
	    }
	    if (cnt > m / 2) {
	    	ans++;
	    }
	}

    cout << ans << "\n";
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cout << a[i][j];
        }
    	cout << "\n";
	}
}

main(){
    //kuka;
	//freopen("test.txt", "r", stdin);
	//freopen("distance.in", "r", stdin);
    //freopen("distance.out", "w", stdout);
    int oylan = 1;
   	cin>>oylan;
    while(oylan--){
        oyan();
    }
}
/*
NOTES
a/b module == (a*b^(module - 2)) % (module);
*/

Compilation message

stones.cpp: In function 'void oyan()':
stones.cpp:120:13: error: 'j' was not declared in this scope
  120 |         if (j % 2 == 0) {
      |             ^
stones.cpp:122:14: error: 'cnt' was not declared in this scope; did you mean 'int'?
  122 |          if (cnt > m / 2) {
      |              ^~~
      |              int
stones.cpp:129:18: error: 'cnt' was not declared in this scope; did you mean 'int'?
  129 |                  cnt++;
      |                  ^~~
      |                  int
stones.cpp:134:18: error: 'cnt' was not declared in this scope; did you mean 'int'?
  134 |              if (cnt > m / 2) {
      |                  ^~~
      |                  int
stones.cpp:141:18: error: 'cnt' was not declared in this scope; did you mean 'int'?
  141 |                  cnt++;
      |                  ^~~
      |                  int
stones.cpp:145:10: error: 'cnt' was not declared in this scope; did you mean 'int'?
  145 |      if (cnt > m / 2) {
      |          ^~~
      |          int
stones.cpp: At global scope:
stones.cpp:159:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  159 | main(){
      | ^~~~