QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#281594 | #3251. 数正方体 | wtcc# | AC ✓ | 2ms | 4036kb | C++14 | 1.4kb | 2023-12-10 13:27:55 | 2023-12-10 13:27:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int long long
//#define endl '\n'
const int N=1009;
const int INF=0x3f3f3f3f;
const int mod=998244353;
inline int read(){
int s=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+(ch^48); ch=getchar();}
return s*=f;
}
inline void write(int x){
if(x>9)write(x/10);
putchar(x%10+48);
}
inline void print(int x){
if(x<0){putchar('-'); x=-x;}
write(x);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> T rnd(T l,T r){return uniform_int_distribution<T>(l,r)(rng);}
inline void file(){
freopen(".in","r",stdin);
freopen(".out","w",stdout);
}
int r,c;
string ch[N];
int x[N],y[N],h[N],tot;
signed main(){
r=read(); c=read();
for(int i=r;i>=1;i--)getline(cin,ch[i]);
x[0]=1; y[0]=0; h[0]=0;
while(1){
int nx=x[tot],ny=y[tot];
if(nx==r)break;
if(tot)nx+=2,ny+=2;
int cnt=0;
while(nx+3<=r&&ch[nx+3][ny]=='+')nx+=3,cnt++;
tot++; x[tot]=nx; y[tot]=ny; h[tot]=h[tot-1]+cnt;
}
int ans=0;
for(int t=1;t<=tot-1;t++){
int nx=x[t],ny=y[t],nh=h[t];
while(1){
while(ch[nx][ny+1]=='-')ny+=4,ans+=nh;
while(ch[nx-1][ny]=='|'&&ch[nx][ny+1]!='-'){
nx-=3,nh--;
if(nx<=2)break;
}
if(nx==1||ny==c-1)break;
if(ch[nx-1][ny]=='.'||ch[nx][ny+1]=='.')break;
}
}
cout<<ans<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3936kb
input:
371 259 ......................................................................+---+---+.................................................................................................................................................................................... ...................................
output:
84826
result:
ok single line: '84826'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3892kb
input:
398 301 ....................................................................................................+---+..............................................................................................................................................................................................
output:
128658
result:
ok single line: '128658'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3960kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---...
output:
250000
result:
ok single line: '250000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 4036kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................
output:
144484
result:
ok single line: '144484'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
395 235 ..............................................................................................+---+---+.................................................................................................................................... ...........................................................
output:
82548
result:
ok single line: '82548'
Test #6:
score: 0
Accepted
time: 2ms
memory: 3948kb
input:
401 301 ....................................................................................................+---+---+---+......................................................................................................................................................................................
output:
125068
result:
ok single line: '125068'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3872kb
input:
367 259 ..................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+................................................................................................................................ ...................................
output:
80503
result:
ok single line: '80503'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3856kb
input:
397 229 ................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+.................................................................... .................................................................
output:
82439
result:
ok single line: '82439'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3944kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................
output:
127263
result:
ok single line: '127263'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3960kb
input:
398 301 ....................................................................................................+---+..............................................................................................................................................................................................
output:
151454
result:
ok single line: '151454'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3896kb
input:
398 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+..........................................................................................................................................................
output:
182883
result:
ok single line: '182883'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3892kb
input:
401 301 ....................................................................................................+---+---+---+---+---+---+---+---+---+---+---+......................................................................................................................................................
output:
209274
result:
ok single line: '209274'