# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
885856 | 2023-12-10T21:58:00 Z | MilosMilutinovic | 무지개나라 (APIO17_rainbow) | C++14 | 0 ms | 0 KB |
#include "rainbow.h" #include<bits/stdc++.h> #define pb push_back #define fi first #define se second #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef long double ld; template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;} template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;} int readint(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int mat[55][55]; void init(int r,int c,int sc,int sr,int m,string s){ mat[sc][sr]=1; for(int i=0;i<m;i++){ if(s[i]=='N') sc--; if(s[i]=='S') sc++; if(s[i]=='E') sr++; if(s[i]=='W') sr--; mat[sc][sr]=1; } } int color(int x1,int y1,int x2,int y2){ int res=0; for(int i=x1;i<=x2;i++) for(int j=y1;j<=y2;j++) res+=1-mat[i][j]; for(int i=x1;i<=x2;i++) for(int j=y1;j<=y2;j++){ if(mat[i][j]==1) continue; if(i+1<=x2&&mat[i+1][j]==0) res--; if(j+1<=y2&&mat[i][j+1]==0) res--; if(i+1<=x2&&j+1<=y2&&mat[i+1][j]==0&&mat[i][j+1]==0&&mat[i+1][j+1]==0) res++; } return res; }