제출 #1230856

#제출 시각아이디문제언어결과실행 시간메모리
1230856djsksbrbfRed-blue table (IZhO19_stones)C++20
컴파일 에러
0 ms0 KiB
using namespace std; typedef long long ll; typedef pair <int, int> pii; #define fi first #define se second #define pb push_back const int MOD = 1e9 + 7; const int MAX = 2e5 + 5; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int tc; cin >> tc; while(tc--){ int n, m; cin >> n >> m; char a[n][m]; for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < m ; j++)a[i][j] = '+'; } bool swit = 0; if(n < m){ swap(n, m); swit = 1; } vector <int> cnt(n, m); bool cont = 1; int r =0, c = 0; ll ans = n; while(cont){ int tmp = r; for(int i = 1 ; i <= n / 2 + 1 ; i++){ cnt[tmp]--; tmp++; if(tmp >= n)tmp = 0; } tmp = r; for(int i = 1 ; i <= n / 2 + 1 ; i++){ if(cnt[tmp] <= m / 2)cont = 0; tmp++; if(tmp >= n)tmp = 0; } if(!cont)break; ans++; for(int i = 1 ; i <= n ; i++){ if(swit)a[c][r] = '-'; else a[r][c] = '-'; r++; if(r >= n)r = 0; } c++; } cout << ans << endl; if(swit){ for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < m ; j++){ cout << (a[i][j] == '-' ? '+' : '-'); } cout << endl; } } else{ for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < m ; j++){ cout << a[i][j]; } cout << endl; } } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

stones.cpp:4:9: error: 'pair' does not name a type
    4 | typedef pair <int, int> pii;
      |         ^~~~
stones.cpp: In function 'int main()':
stones.cpp:12:9: error: 'ios_base' has not been declared
   12 |         ios_base::sync_with_stdio(0);
      |         ^~~~~~~~
stones.cpp:13:9: error: 'cin' was not declared in this scope
   13 |         cin.tie(0);
      |         ^~~
stones.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | 
stones.cpp:25:25: error: 'swap' was not declared in this scope
   25 |                         swap(n, m);
      |                         ^~~~
stones.cpp:29:17: error: 'vector' was not declared in this scope
   29 |                 vector <int> cnt(n, m);
      |                 ^~~~~~
stones.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | 
stones.cpp:29:25: error: expected primary-expression before 'int'
   29 |                 vector <int> cnt(n, m);
      |                         ^~~
stones.cpp:37:33: error: 'cnt' was not declared in this scope; did you mean 'cont'?
   37 |                                 cnt[tmp]--;
      |                                 ^~~
      |                                 cont
stones.cpp:44:36: error: 'cnt' was not declared in this scope; did you mean 'cont'?
   44 |                                 if(cnt[tmp] <= m / 2)cont = 0;
      |                                    ^~~
      |                                    cont
stones.cpp:63:17: error: 'cout' was not declared in this scope
   63 |                 cout << ans << endl;
      |                 ^~~~
stones.cpp:63:17: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
stones.cpp:63:32: error: 'endl' was not declared in this scope
   63 |                 cout << ans << endl;
      |                                ^~~~
stones.cpp:1:1: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
  +++ |+#include <ostream>
    1 |