답안 #904631

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
904631 2024-01-12T06:42:30 Z vjudge1 무지개나라 (APIO17_rainbow) C++17
0 / 100
3000 ms 173208 KB
#include <bits/stdc++.h>

#pragma optimize("03")
#pragma target("avx2")

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(s) (int)s.size()
#define y1 yy
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define in insert

const int MAX=3e5+5;
const int B=224;
const int N=1e6;
const int block=450;
const int maxB=MAX/B+10;
const ll inf=1e18;  
const int mod=1e9+7;
const int mod1=1e9+9;
const int logg=15;

int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

int binpow(int a,int n){
  if(!n)return 1;
  if(n%2==1)return a*binpow(a,n-1)%mod;
  int k=binpow(a,n/2);
  return k*k%mod;
}

multiset<pii> pt;

void init(int R, int C, int sr, int sc, int M, char *s){
  pt.in({sr,sc});
  for(int i=0;i<M;i++){
    if(s[i]=='N')sr--;
    if(s[i]=='S')sr++;
    if(s[i]=='W')sc--;
    if(s[i]=='E')sc++;
    // cout<<sr<<" "<<sc<<"\n";
    pt.in({sr,sc});
  }
}

bool inthe(int ar, int br, int ac, int bc,pii x){
  return ar<=x.F&&x.F<=ac&&br<=x.S&&x.S<=bc;
}


set<pii> gr;
map<pii,int> mp;

void dfs(pii x){
  mp[x];
  for(int i=0;i<4;i++){
    int nx=x.F+dx[i],ny=x.S+dy[i];
    if(!mp.count({nx,ny})&&gr.count({nx,ny}))dfs({nx,ny});
  }
}

int colour(int ar, int br, int ac, int bc) {
  for(int i=ar-1;i<=ac+1;i++){
    pt.in({i,br-1});
    pt.in({i,bc+1});
  }
  for(int i=br-1;i<=bc+1;i++){
    pt.in({ar-1,i});
    pt.in({ac+1,i});
  }
  gr.clear();
  mp.clear();
  for(pii x:pt){
    for(int i=0;i<8;i++){
      int nx=x.F+dx[i],ny=x.S+dy[i];
      if(!pt.count({nx,ny})&&inthe(ar,br,ac,bc,{nx,ny})){
        gr.in({nx,ny});
      }
    }
  }
  int ans=0;
  for(pii x:gr){
    if(!mp.count(x)){
      dfs(x);
      ans++;
    }
  }
  // for(int i=ar-1;i<=ac+1;i++){
  //   pt.erase(pt.find({i,br-1}));
  //   pt.erase(pt.find({i,bc+1}));
  // }
  // for(int i=br-1;i<=bc+1;i++){
  //   pt.erase(pt.find({ar-1,i}));
  //   pt.erase(pt.find({ac+1,i}));
  // }
  return ans;
}

// int main(){
//   int r,c,m,q;
//   cin>>r>>c>>m>>q;
//   int sr,sc;
//   cin>>sr>>sc;
//   char s[MAX];
//   for(int i=0;i<m;i++)cin>>s[i];
//   init(r,c,sr,sc,m,s);
//   while(q--){
//     int ar,br,ac,bc;
//     cin>>ar>>br>>ac>>bc;
//     cout<<colour(ar,br,ac,bc)<<"\n";
//   }
// }

Compilation message

rainbow.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize("03")
      | 
rainbow.cpp:4: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    4 | #pragma target("avx2")
      |
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3054 ms 1564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1060 ms 81676 KB Output is correct
3 Correct 1065 ms 81696 KB Output is correct
4 Correct 999 ms 77472 KB Output is correct
5 Correct 483 ms 38888 KB Output is correct
6 Correct 1488 ms 128880 KB Output is correct
7 Incorrect 2041 ms 173208 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3054 ms 1564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3054 ms 1564 KB Time limit exceeded
2 Halted 0 ms 0 KB -