Submission #1187281


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long
int w,h,v,t,l;
struct Point{
  int x,y;
  Point(){}
  Point(int x,int y):x(x),y(y){}
  Point operator+(Point a){return Point(x+a.x,y+a.y);};
  Point operator-(Point a){return Point(x-a.x,y-a.y);};
  bool operator==(Point a)const{
    return x==a.x&&y==a.y;
  }
};
Point s,e;
int norm(Point p){
  return p.x*p.x+p.y*p.y;
}
int norm2(Point p){
  p.x*=w;p.y*=h;
  p=p-s;
  //cout<<p.x*p.x+p.y*p.y<<endl;
  return p.x*p.x+p.y*p.y;
}
int check(Point p){
  int res=0;
  if(norm2(p)<=l*l) res++;
  p.x++;
  if(norm2(p)<=l*l) res++;
  p.y++;
  if(norm2(p)<=l*l) res++;
  p.x--;
  if(norm2(p)<=l*l) res++;
  p.y--;
  if(!res){
    if(p.y==0){
      if(p.x>=0){
    //cout<<s.x+p.x*w<<":"<<l<<endl;
    if(p.x*w-s.x<=l) return 5;
      }else{
    if(s.x-(p.x+1)*w<=l) return 5;
      }
    }
    if(p.x==0){
      if(p.y>=0){
    if(p.y*h-s.y<=l) return 5;
      }else{
    if(s.y-(p.y+1)*h<=l) return 5;
      }
    }
  }
  return res;
}
int check2(Point p){
  if(check(p)==4) return 0;
  Point r=Point(p.x*w,p.y*h);
  if(abs(p.x)%2) r.x+=w-e.x;
  else r.x+=e.x;
  if(abs(p.y)%2) r.y+=h-e.y;
  else r.y+=e.y;
  return norm(r-s)<=l*l;
}
 
signed main(){
  cin>>w>>h>>v>>t;
  cin>>s.x>>s.y>>e.x>>e.y;
 
  int ans=0;
  l=v*t;
  //cout<<l<<endl;
  Point tp,bt,nt,nb;
  tp=bt=Point((s.x+l)/w,0);
  check(Point(0,0));
  for(int i=bt.x+1;s.x-l<=(i+2)*w;i--){
    tp.x=bt.x=i;
 
    nt=tp;nb=bt;
    nt.y++;nb.y--;
    while(check(nt)==4){
      tp=nt;
      nt.y++;
    }
    while(check(nb)==4){
      bt=nb;
      nb.y--;
    }
 
    while(check(tp)!=4&&tp.y>bt.y){
      tp.y--;
    }
    while(check(bt)!=4&&tp.y>bt.y){
      bt.y++;
    }
 
    nt=tp;nb=bt;
    if(tp==bt) nb.y--;    
    while(check(nt)){
      ans+=check2(nt);
      nt.y++;
    }
    while(check(nb)){
      ans+=check2(nb);
      nb.y--;
    }
     
    //cout<<tp.x<<" "<<tp.y<<":"<<bt.x<<" "<<bt.y<<endl;
    //cout<<check(tp)<<" "<<check(bt)<<endl;
    assert(tp.y>=bt.y);
    if(check(tp)==4&&check(bt)==4) ans+=tp.y-bt.y+1;
  }
   
  cout<<ans<<endl;
  return 0;
}

Submission Info

Submission Time
Task C - Wave Attack
User beet
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2209 Byte
Status AC
Exec Time 141 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 36
Set Name Test Cases
All 00-sample1.txt, 00-sample2.txt, 00-sample3.txt, 10_rand_small00.txt, 10_rand_small01.txt, 10_rand_small02.txt, 10_rand_small03.txt, 10_rand_small04.txt, 10_rand_small05.txt, 10_rand_small06.txt, 10_rand_small07.txt, 10_rand_small08.txt, 10_rand_small09.txt, 20_rand_medium00.txt, 20_rand_medium01.txt, 20_rand_medium02.txt, 20_rand_medium03.txt, 20_rand_medium04.txt, 20_rand_medium05.txt, 20_rand_medium06.txt, 20_rand_medium07.txt, 20_rand_medium08.txt, 20_rand_medium09.txt, 30_rand_large00.txt, 30_rand_large01.txt, 30_rand_large02.txt, 30_rand_large03.txt, 30_rand_large04.txt, 30_rand_large05.txt, 30_rand_large06.txt, 30_rand_large07.txt, 30_rand_large08.txt, 30_rand_large09.txt, maximum1.txt, minimum1.txt, minimum2.txt
Case Name Status Exec Time Memory
00-sample1.txt AC 1 ms 256 KB
00-sample2.txt AC 1 ms 256 KB
00-sample3.txt AC 141 ms 256 KB
10_rand_small00.txt AC 1 ms 256 KB
10_rand_small01.txt AC 1 ms 256 KB
10_rand_small02.txt AC 1 ms 256 KB
10_rand_small03.txt AC 1 ms 256 KB
10_rand_small04.txt AC 1 ms 256 KB
10_rand_small05.txt AC 1 ms 256 KB
10_rand_small06.txt AC 1 ms 256 KB
10_rand_small07.txt AC 1 ms 256 KB
10_rand_small08.txt AC 1 ms 256 KB
10_rand_small09.txt AC 1 ms 256 KB
20_rand_medium00.txt AC 1 ms 256 KB
20_rand_medium01.txt AC 1 ms 256 KB
20_rand_medium02.txt AC 1 ms 256 KB
20_rand_medium03.txt AC 1 ms 256 KB
20_rand_medium04.txt AC 1 ms 256 KB
20_rand_medium05.txt AC 1 ms 256 KB
20_rand_medium06.txt AC 1 ms 256 KB
20_rand_medium07.txt AC 1 ms 256 KB
20_rand_medium08.txt AC 1 ms 256 KB
20_rand_medium09.txt AC 1 ms 256 KB
30_rand_large00.txt AC 1 ms 256 KB
30_rand_large01.txt AC 1 ms 256 KB
30_rand_large02.txt AC 1 ms 256 KB
30_rand_large03.txt AC 1 ms 256 KB
30_rand_large04.txt AC 1 ms 256 KB
30_rand_large05.txt AC 1 ms 256 KB
30_rand_large06.txt AC 1 ms 256 KB
30_rand_large07.txt AC 1 ms 256 KB
30_rand_large08.txt AC 1 ms 256 KB
30_rand_large09.txt AC 1 ms 256 KB
maximum1.txt AC 104 ms 256 KB
minimum1.txt AC 1 ms 256 KB
minimum2.txt AC 1 ms 256 KB