QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#698191#9521. Giving Directions in HarbinAnotherDayofSun#AC ✓3ms3972kbC++143.4kb2024-11-01 18:04:302024-11-01 18:04:31

Judging History

你现在查看的是最新测评结果

  • [2024-11-01 18:04:31]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3972kb
  • [2024-11-01 18:04:30]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define ull unsigned long long
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i,k,j) for(int i=(k);i>=(j);i--)
#define For(i,k,j) for(int i=(k);i<=(j);i++)
#define Foe(i,u) for(int i=lst[u],v=e[i].v;i;i=e[i].nxt,v=e[i].v)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Fin(s) freopen(s,"r",stdin)
#define Fout(s) freopen(s,"w",stdout)
#define file(s) Fin(s".in"),Fout(s".out")
#define INF ((1<<30)-1)
//#define int long long
const int P=998244353; //
using namespace std;
template<typename T>inline void ckmax(T &a,T b) {(a<b)&&(a=b);}
template<typename T>inline void ckmin(T &a,T b) {(a>b)&&(a=b);}
inline int mul(int a,int b) {return 1ll*a*b%P;}
inline int add(int a,int b) {return a+b>=P?a+b-P:a+b;}
inline int sub(int a,int b) {return a-b>=0?a-b:a-b+P;}
inline void mulmod(int &a,int b) {a=mul(a, b);}
inline void addmod(int &a,int b) {((a+=b)>=P)&&(a-=P);}
inline void submod(int &a,int b) {((a-=b)<0)&&(a+=P);}
inline int ksm(int a,int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline void fprint(const vector<int> &f) {for(int i=0;i<(int)f.size();i++) fprintf(stderr,"%d ",f[i]); fprintf(stderr,"\n");}
inline int inv(int a) {return ksm(a,P-2);}
namespace FastIO {
	const int SIZE=1<<16; char buf[SIZE],obuf[SIZE],str[64]; int bi=SIZE,bn=SIZE,opt;
	int read(char *s) {
		while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
		int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
	}
	bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
	void write(int x) {
		if(!x) obuf[opt++]='0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
		if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}
	}
	void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}}
	void Fflush() {if (opt) fwrite(obuf,1,opt,stdout); opt=0;}
};
inline int read() {int x; FI(x); return x;}
const int MN=1e5+5; 
int a[MN],n; char s[55]; 
void works() {
    n=read();
    int x=0,y=0; 
    For(i,1,n) {
        FI(s); int t=read();
        if(s[0]=='E') x+=t; 
        if(s[0]=='W') x-=t; 
        if(s[0]=='S') y+=t; 
        if(s[0]=='N') y-=t; 
    }
    if(x==0&&y==0) printf("7 S\nZ 1\nL\nZ 1\nL\nZ 1\nL\nZ 1\n"); 
    else if(x==0) {
        if(y>0) printf("1 S\n"),printf("Z %d\n",y);
        else printf("1 N\n"),printf("Z %d\n",-y);
    }
    else if(y==0) {
        if(x>0) printf("1 E\n"),printf("Z %d\n",x);
        else printf("1 W\n"),printf("Z %d\n",-x);
    } 
    else {
        
        if(y>0) printf("3 S\n"),printf("Z %d\n",y);
        else printf("3 N\n"),printf("Z %d\n",-y);
        if((x>0)^(y>0)) printf("R\n"); 
        else printf("L\n"); 
        if(x>0) printf("Z %d\n",x);
        else printf("Z %d\n",-x);
    }
}
int main(){
	#ifdef wasa855
		freopen("pro.in","r",stdin);
		freopen("pro.out","w",stdout);
	#endif
	int T=read();  
	while(T--) {
		works(); 
	}
	return FastIO::Fflush(),0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3868kb

input:

1
2
S 2
E 1

output:

3 S
Z 2
L
Z 1

result:

ok ok (1 test case)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

99
4
E 6
N 1
W 2
S 8
8
W 10
N 1
E 10
S 2
E 2
N 2
W 2
S 1
9
N 5
E 4
N 7
E 6
S 9
E 8
N 4
W 6
N 7
6
N 6
E 6
N 8
W 9
S 7
E 2
8
E 6
S 9
W 5
S 4
W 6
N 4
E 5
N 9
8
N 6
W 10
N 6
W 6
S 6
E 6
S 6
E 10
10
N 7
W 3
N 5
W 5
S 8
W 10
N 6
E 9
N 8
E 8
8
W 9
N 10
E 6
S 10
E 9
S 10
W 6
N 10
4
W 5
N 1
E 5
S 1
4
W 4
S 8...

output:

3 S
Z 7
L
Z 4
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
3 N
Z 14
R
Z 12
3 N
Z 7
L
Z 1
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
3 N
Z 18
L
Z 1
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
3 S
Z 3
L
Z 9
1 W
Z 10
7 S
Z 1
L
Z 1
L
Z 1
L
Z 1
3 S
Z 16
R...

result:

ok ok (99 test cases)

Test #3:

score: 0
Accepted
time: 3ms
memory: 3972kb

input:

10000
1
W 9
1
N 3
10
W 10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