QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#133289#1774. Customs ControlsttestWA 1ms3856kbC++141.6kb2023-08-01 22:11:122023-08-01 22:11:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-01 22:11:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3856kb
  • [2023-08-01 22:11:12]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define pii pair<int,int>
using namespace std;

const int maxn=100005;
const int inf=0x3f3f3f3f;

int ans[maxn];
bool p[maxn];
bool q[maxn];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T;
	memset(ans,-1,sizeof(ans));
	while(T--) {
		int n,m,k;
		cin>>n>>m>>k;
		bool rev=false,ok=true;
		if(n-k>k) {
			rev=true;
			k=n-k;
		}
		for(int i=1;i<=n;i++) {
			int x;
			cin>>x;
		}
		for(int i=1;i<=m;i++) {
			int x,y;
			cin>>x>>y;
			if(x>y) {
				swap(x,y);
			}
			if(x==1) {
				p[y]=true;
			}
			if(y==n) {
				q[x]=true;
			}
		}
		auto get=[&](int i) {
			if(!k) {
				ans[i]=true;
			} else {
				k--;
				ans[i]=false;
			}
		};
		if(n==2) {
			if(k==1) {
				ok=false;
			} else {
				for(int i=1;i<=n;i++) {
					get(i);
				}
			}
		} else if(p[n]) {
			get(1);
			get(n);
			for(int i=2;i<=n-1;i++) {
				get(i);
			}
		} else {
			int sum=1;
			for(int i=1;i<=n;i++) {
				sum+=p[i]&&!q[i];
			}
			if(sum<=k) {
				get(1);
				for(int i=1;i<=n;i++) {
					if(p[i]&&!q[i]) {
						get(i);
					}
				}
			} else {
				get(n);
				for(int i=1;i<=n;i++) {
					if(q[i]&&!p[i]) {
						get(i);
					}
				}
			}
			for(int i=1;i<=n;i++) {
				if(ans[i]==-1) {
					get(i);
				}
			}
		}
		if(!ok) {
			cout<<"impossible\n";
		} else {
			for(int i=1;i<=n;i++) {
				cout<<(ans[i]^rev?'S':'N');
			}
			cout<<"\n";
		}
		for(int i=1;i<=n;i++) {
			p[i]=q[i]=false;
			ans[i]=-1;
		}
	} 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3856kb

input:

5 10 2
1 1 1 1 1
3 4
5 4
3 1
4 1
3 5
2 1
2 4
2 5
1 5
2 3

output:


result:

wrong output format Unexpected end of file - token expected