제출 #678538

#제출 시각아이디문제언어결과실행 시간메모리
678538uyluluDango Maker (JOI18_dango_maker)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ld long double #define int __int16 #define endl "\n" const int N = 3e3; vector<int> adj[N*N + 1]; char grid[N + 1][N + 1]; map<pair<pair<int,int>,pair<int,int>>,int> mp; int dp[N*N + 1][2]; int f(int s,int pa,bool type) { if(dp[s][type] != -1) return dp[s][type]; int res = type; for(auto u : adj[s]) { if(u == pa) continue; res = (res + f(u,s,!type)); } return dp[s][type] = res; } signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); int n,m; cin>>n>>m; memset(dp,-1,sizeof(dp)); for(int i = 1;i <= n;i++) { for(int j = 1;j <= m;j++) { cin>>grid[i][j]; } } int curr = 1; for(int i = 1;i <= n;i++) { for(int j = 1;j <= m;j++) { int cnt = 0; if(j <= m - 2 && grid[i][j] == 'R' && grid[i][j + 1] == 'G' && grid[i][j + 2] == 'W') { mp[{{i,j},{i,j + 2}}] = curr; // intersect G pair<pair<int,int>,pair<int,int>> tmp = {{i - 1,j + 1},{i + 1,j + 1}}; if(mp[tmp]) { adj[curr].push_back(mp[tmp]); adj[mp[tmp]].push_back(curr); } // intersect W tmp = {{i - 2,j + 2},{i - 2,j}}; if(mp[tmp]) { adj[curr].push_back(mp[tmp]); adj[mp[tmp]].push_back(curr); } curr++; cnt++; } if(i <= m - 2 && grid[i][j] == 'R' && grid[i + 1][j] == 'G' && grid[i + 2][j] == 'W') { mp[{{i,j},{i + 2,j}}] = curr; // intersect G pair<pair<int,int>,pair<int,int>> tmp = {{i + 1,j - 1},{i + 1,j + 1}}; if(mp[tmp]) { adj[curr].push_back(mp[tmp]); adj[mp[tmp]].push_back(curr); } curr++; cnt++; } if(cnt == 2) { adj[curr - 2].push_back(curr - 1); adj[curr - 1].push_back(curr - 2); } } } int kq = 0; for(int i = 1;i < curr;i++) { if(dp[i][0] == -1) { kq += max(f(i,-1,0),f(i,-1,1)); } } cout<<kq<<endl; return 0; }

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

dango_maker.cpp:5:13: error: '__int16' does not name a type; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:8:7: note: in expansion of macro 'int'
    8 | const int N = 3e3;
      |       ^~~
dango_maker.cpp:5:13: error: '__int16' was not declared in this scope; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:10:8: note: in expansion of macro 'int'
   10 | vector<int> adj[N*N + 1];
      |        ^~~
dango_maker.cpp:10:11: error: template argument 1 is invalid
   10 | vector<int> adj[N*N + 1];
      |           ^
dango_maker.cpp:10:11: error: template argument 2 is invalid
dango_maker.cpp:10:17: error: 'N' was not declared in this scope
   10 | vector<int> adj[N*N + 1];
      |                 ^
dango_maker.cpp:10:19: error: 'N' was not declared in this scope
   10 | vector<int> adj[N*N + 1];
      |                   ^
dango_maker.cpp:11:11: error: 'N' was not declared in this scope
   11 | char grid[N + 1][N + 1];
      |           ^
dango_maker.cpp:11:18: error: 'N' was not declared in this scope
   11 | char grid[N + 1][N + 1];
      |                  ^
dango_maker.cpp:5:13: error: '__int16' was not declared in this scope; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:13:15: note: in expansion of macro 'int'
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |               ^~~
dango_maker.cpp:5:13: error: '__int16' was not declared in this scope; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:13:19: note: in expansion of macro 'int'
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                   ^~~
dango_maker.cpp:13:22: error: template argument 1 is invalid
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                      ^
dango_maker.cpp:13:22: error: template argument 2 is invalid
dango_maker.cpp:5:13: error: '__int16' was not declared in this scope; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:13:29: note: in expansion of macro 'int'
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                             ^~~
dango_maker.cpp:5:13: error: '__int16' was not declared in this scope; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:13:33: note: in expansion of macro 'int'
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                                 ^~~
dango_maker.cpp:5:13: error: template argument 1 is invalid
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:13:33: note: in expansion of macro 'int'
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                                 ^~~
dango_maker.cpp:5:13: error: template argument 2 is invalid
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:13:33: note: in expansion of macro 'int'
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                                 ^~~
dango_maker.cpp:13:36: error: template argument 1 is invalid
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                                    ^~
dango_maker.cpp:13:36: error: template argument 2 is invalid
dango_maker.cpp:5:13: error: '__int16' was not declared in this scope; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:13:39: note: in expansion of macro 'int'
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                                       ^~~
dango_maker.cpp:13:42: error: template argument 1 is invalid
   13 | map<pair<pair<int,int>,pair<int,int>>,int> mp;
      |                                          ^
dango_maker.cpp:13:42: error: template argument 2 is invalid
dango_maker.cpp:13:42: error: template argument 3 is invalid
dango_maker.cpp:13:42: error: template argument 4 is invalid
dango_maker.cpp:5:13: error: '__int16' does not name a type; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:15:1: note: in expansion of macro 'int'
   15 | int dp[N*N + 1][2];
      | ^~~
dango_maker.cpp:5:13: error: '__int16' does not name a type; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:17:1: note: in expansion of macro 'int'
   17 | int f(int s,int pa,bool type) {
      | ^~~
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:5:13: error: '__int16' was not declared in this scope; did you mean '__int16_t'?
    5 | #define int __int16
      |             ^~~~~~~
dango_maker.cpp:34:5: note: in expansion of macro 'int'
   34 |     int n,m;
      |     ^~~
dango_maker.cpp:35:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   35 |     cin>>n>>m;
      |          ^
      |          yn
dango_maker.cpp:35:13: error: 'm' was not declared in this scope; did you mean 'mp'?
   35 |     cin>>n>>m;
      |             ^
      |             mp
dango_maker.cpp:36:12: error: 'dp' was not declared in this scope; did you mean 'mp'?
   36 |     memset(dp,-1,sizeof(dp));
      |            ^~
      |            mp
dango_maker.cpp:38:13: error: expected ';' before 'i'
   38 |     for(int i = 1;i <= n;i++) {
      |             ^
dango_maker.cpp:38:19: error: 'i' was not declared in this scope
   38 |     for(int i = 1;i <= n;i++) {
      |                   ^
dango_maker.cpp:39:17: error: expected ';' before 'j'
   39 |         for(int j = 1;j <= m;j++) {
      |                 ^
dango_maker.cpp:39:23: error: 'j' was not declared in this scope; did you mean 'jn'?
   39 |         for(int j = 1;j <= m;j++) {
      |                       ^
      |                       jn
dango_maker.cpp:40:18: error: 'grid' was not declared in this scope
   40 |             cin>>grid[i][j];
      |                  ^~~~
dango_maker.cpp:44:9: error: expected ';' before 'curr'
   44 |     int curr = 1;
      |         ^~~~
dango_maker.cpp:46:13: error: expected ';' before 'i'
   46 |     for(int i = 1;i <= n;i++) {
      |             ^
dango_maker.cpp:46:19: error: 'i' was not declared in this scope
   46 |     for(int i = 1;i <= n;i++) {
      |                   ^
dango_maker.cpp:47:17: error: expected ';' before 'j'
   47 |         for(int j = 1;j <= m;j++) {
      |                 ^
dango_maker.cpp:47:23: error: 'j' was not declared in this scope; did you mean 'jn'?
   47 |         for(int j = 1;j <= m;j++) {
      |                       ^
      |                       jn
dango_maker.cpp:48:17: error: expected ';' before 'cnt'
   48 |             int cnt = 0;
      |                 ^~~
dango_maker.cpp:50:30: error: 'grid' was not declared in this scope
   50 |             if(j <= m - 2 && grid[i][j] == 'R' && grid[i][j + 1] == 'G' && grid[i][j + 2] == 'W') {
      |                              ^~~~
dango_maker.cpp:51:19: error: invalid types 'int[<brace-enclosed initializer list>]' for array subscript
   51 |                 mp[{{i,j},{i,j + 2}}] = curr;
      |                   ^
dango_maker.cpp:51:41: error: 'curr' was not declared in this scope
   51 |                 mp[{{i,j},{i,j + 2}}] = curr;
      |                                         ^~~~
dango_maker.cpp:54:48: error: template argument 1 is invalid
   54 |                 pair<pair<int,int>,pair<int,int>> tmp = {{i - 1,j + 1},{i + 1,j + 1}};
      |                                                ^~
dango_maker.cpp:54:48: error: template argument 2 is invalid
dango_maker.cpp:54:51: error: scalar object 'tmp' requires one element in initializer
   54 |                 pair<pair<int,int>,pair<int,int>> tmp = {{i - 1,j + 1},{i + 1,j + 1}};
      |                                                   ^~~
dango_maker.cpp:56:21: error: 'adj' was not declared in this scope
   56 |                     adj[curr].push_back(mp[tmp]);
      |                     ^~~
dango_maker.cpp:62:21: error: 'adj' was not declared in this scope
   62 |                     adj[curr].push_back(mp[tmp]);
      |                     ^~~
dango_maker.cpp:67:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   67 |                 cnt++;
      |                 ^~~
      |                 int
dango_maker.cpp:69:30: error: 'grid' was not declared in this scope
   69 |             if(i <= m - 2 && grid[i][j] == 'R' && grid[i + 1][j] == 'G' && grid[i + 2][j] == 'W') {
      |                              ^~~~
dango_maker.cpp:70:19: error: invalid types 'int[<brace-enclosed initializer list>]' for array subscript
   70 |                 mp[{{i,j},{i + 2,j}}] = curr;
      |                   ^
dango_maker.cpp:70:41: error: 'curr' was not declared in this scope
   70 |                 mp[{{i,j},{i + 2,j}}] = curr;
      |                                         ^~~~
dango_maker.cpp:73:48: error: template argument 1 is invalid
   73 |                 pair<pair<int,int>,pair<int,int>> tmp = {{i + 1,j - 1},{i + 1,j + 1}};
      |                                                ^~
dango_maker.cpp:73:48: error: template argument 2 is invalid
dango_maker.cpp:73:51: error: scalar object 'tmp' requires one element in initializer
   73 |                 pair<pair<int,int>,pair<int,int>> tmp = {{i + 1,j - 1},{i + 1,j + 1}};
      |                                                   ^~~
dango_maker.cpp:75:21: error: 'adj' was not declared in this scope
   75 |                     adj[curr].push_back(mp[tmp]);
      |                     ^~~
dango_maker.cpp:79:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   79 |                 cnt++;
      |                 ^~~
      |                 int
dango_maker.cpp:81:16: error: 'cnt' was not declared in this scope; did you mean 'int'?
   81 |             if(cnt == 2) {
      |                ^~~
      |                int
dango_maker.cpp:82:17: error: 'adj' was not declared in this scope
   82 |                 adj[curr - 2].push_back(curr - 1);
      |                 ^~~
dango_maker.cpp:82:21: error: 'curr' was not declared in this scope
   82 |                 adj[curr - 2].push_back(curr - 1);
      |                     ^~~~
dango_maker.cpp:87:9: error: expected ';' before 'kq'
   87 |     int kq = 0;
      |         ^~
dango_maker.cpp:88:13: error: expected ';' before 'i'
   88 |     for(int i = 1;i < curr;i++) {
      |             ^
dango_maker.cpp:88:19: error: 'i' was not declared in this scope
   88 |     for(int i = 1;i < curr;i++) {
      |                   ^
dango_maker.cpp:88:23: error: 'curr' was not declared in this scope
   88 |     for(int i = 1;i < curr;i++) {
      |                       ^~~~
dango_maker.cpp:90:13: error: 'kq' was not declared in this scope
   90 |             kq += max(f(i,-1,0),f(i,-1,1));
      |             ^~
dango_maker.cpp:90:23: error: 'f' was not declared in this scope
   90 |             kq += max(f(i,-1,0),f(i,-1,1));
      |                       ^
dango_maker.cpp:93:11: error: 'kq' was not declared in this scope
   93 |     cout<<kq<<endl;
      |           ^~