QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#244033 | #7022. Best ACMer Solves the Hardest Problem | yiyiyi | AC ✓ | 2763ms | 688168kb | C++20 | 3.4kb | 2023-11-08 20:35:35 | 2023-11-08 20:35:36 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<deque>
#include<bitset>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<cstdlib>
#include<ctype.h>
#include<ctime>
#include<functional>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define debug puts("debug")
#define mid ((L+R)>>1)
#define lc (id<<1)
#define rc (id<<1|1)
const int maxn=10010;
const int maxm=50050;
const double PI=acos(-1.0);
const double eps=1e-6;
const LL mod=1e9+7;
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL qpow(LL a,LL b,LL c){LL r=1; for(;b;b>>=1,a=a*a%c)if(b&1)r=r*a%c;return r;}
struct Edge{int v,w,next;};
template<class T>
ostream & operator<<(ostream &out,vector<T>&v){
for(auto x:v)cout<<x<<' ';
return out;
}
void read(LL &n){
n=0; char c=getchar();
while(c<'0'||c>'9')c=getchar();
while(c>='0'&&c<='9') n=(n<<3)+(n<<1)+(c-'0'),c=getchar();
}
LL C[6005][6005];
LL dir[4][2]={1,1,1,-1,-1,1,-1,-1};
bool ojbk(LL x,LL y){
if(x<1||x>6000||y<1||y>6000||C[x][y]==0)return 0;
return 1;
}
#define pll pair<LL,LL>
const LL MAX=10000000+15;
vector<pll> cl,a[MAX];
void AC(){
LL T,n,m,cas=0;
scanf("%lld",&T);
while(T--){
scanf("%lld%lld",&n,&m);
LL last=0;
LL x,y,w,k,op;
for(int i=1;i<=n;++i){
scanf("%lld%lld%lld",&x,&y,&w);
cl.pb(mp(x,y));
C[x][y]+=w;
}
printf("Case #%lld:\n",++cas);
while(m--){
scanf("%lld%lld%lld",&op,&x,&y);
x=(x+last)%6000+1;
y=(y+last)%6000+1;cl.pb(mp(x,y));
if(op==1){
scanf("%lld",&w);
C[x][y]=w;
}
else if(op==2){
C[x][y]=0;
}
else if(op==3){
scanf("%lld%lld",&k,&w);
set<pll>S;
for(auto v:a[k]){
for(int i=0;i<4;++i){
LL sx=x+v.fi*dir[i][0],sy=y+v.se*dir[i][1];
if(ojbk(sx,sy))S.insert(mp(sx,sy));
}
}for(auto o:S){
C[o.fi][o.se]+=w;
}
}
else{
scanf("%lld",&k);
LL ans=0;
set<pll>S;
for(auto v:a[k]){
for(int i=0;i<4;++i){
LL sx=x+v.fi*dir[i][0],sy=y+v.se*dir[i][1];
if(ojbk(sx,sy))S.insert(mp(sx,sy));
}
}for(auto o:S){
ans+=C[o.fi][o.se];
}
printf("%lld\n",ans);
last=ans;
}
}
for(auto v:cl)C[v.fi][v.se]=0;
cl.clear();
}
}
int main(){
for(LL i=0;i<=6000;++i){
for(LL j=0;j<=6000;++j){
if(i*i+j*j>MAX-15)break;
a[i*i+j*j].pb(mp(i,j));
}
}
AC();
return 0;
}
/*
1
3 6
2999 3000 1
3001 3000 1
3000 2999 1
1 2999 3000 1
4 2999 2999 1
2 2995 2996
3 2995 2995 1 1
4 2995 2995 1
4 3000 3000 1
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1115ms
memory: 405172kb
input:
1 3 6 2999 3000 1 3001 3000 1 3000 2999 1 1 2999 3000 1 4 2999 2999 1 2 2995 2996 3 2995 2995 1 1 4 2995 2995 1 4 3000 3000 1
output:
Case #1: 4 6 0
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 2763ms
memory: 688168kb
input:
1000 10 10 3505 4093 1071 2828 5767 1951 4087 1947 2419 1348 1177 6000 271 3657 1998 4584 132 495 4260 4693 129 5112 3484 1918 5754 3661 3066 1629 1302 1691 1 5838 2560 2113 2 4086 1946 2 4583 131 4 4970 4439 4284065 3 2945 677 1239925 5721 4 1523 2487 2014037 2 876 3815 3 5116 5955 680746 5170 3 79...
output:
Case #1: 2113 1951 Case #2: 33271 30497 30497 Case #3: 29279 47107 Case #4: 852 3353 7244 5176 Case #5: 11088 Case #6: 122515 185005 Case #7: 31427 78290 Case #8: 4549 2091 12806 Case #9: 188803 Case #10: 83837 Case #11: 58111 58111 140591 Case #12: 5457 4290 Case #13: 22748 148509 Case #14: 1674 60...
result:
ok 405746 lines