QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#62160#2838. 2D Geometrydefathom#RE 3ms7856kbC++141.7kb2022-11-17 16:23:522022-11-17 16:23:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-17 16:23:53]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:7856kb
  • [2022-11-17 16:23:52]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
const int N=1e6+5;
//const ll mod=998244373;
using namespace std;

int n,t;
int x[N],y[N],p[N];
int cnt,ans;

int main()
{
	srand(time(0));
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
	while(scanf("%d",&n)!=EOF)
	  {
	  	cnt=0;
	  	if(n==1)
	  	  {
	  	  	printf("1\n");
	  	  	continue;
	  	  }
	  	if(n==2)
	  	  {
	  	  	printf("2\n");
	  	  	continue;
	  	  }
	  	queue<pair<int,int>>q;
	    for(int i=1;i<=n;++i)
	      {
	      	cin>>x[i]>>y[i];
	        p[i]=i;
	      } 
	    random_shuffle(p+1,p+1+n);
        for(int i=1;i<=n;++i)
          {
          	int g=p[i];
          	q.push({x[g],y[g]});
          }
        int nx1=q.front().first;
        int ny1=q.front().second;
        q.pop();
        int nx2=q.front().first;
        int ny2=q.front().second;
        q.pop();
        while(!q.empty())
          {
          	//++cnt;
          	if(cnt==10000)
          	  break;
            int nx3=q.front().first;
            int ny3=q.front().second;
            q.pop();

            if(nx1==nx2&&nx2==nx3)
              {
              	++cnt;
              	q.push({nx3,ny3});
              	continue;
              }
            if(ny1==ny2&&ny2==ny3)
              {
              	++cnt;
              	q.push({nx3,ny3});
              	continue;
              }
               if(!q.size())
              break;
            nx1=q.front().first;
            ny1=q.front().second;
            q.pop();
            nx2=q.front().first;
            ny2=q.front().second;
            q.pop();
          }
        if(q.size())
          printf("%d\n",q.size()+2);
        else
          printf("0\n");
     }
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 7856kb

input:

3
0 0
0 1
0 2
3
0 0
0 1
1 0
6
0 0
0 1
0 2
0 3
1 1
1 2

output:

3
0
0

result:

ok 3 lines

Test #2:

score: -100
Runtime Error

input:

1
0 0
2
0 0
1 1
3
0 0
0 1
0 2
3
0 0
0 1
1 0
4
3 0
0 2
3 3
3 1
4
2 3
1 1
0 3
0 2
4
0 0
0 3
0 2
0 1
5
8 6
9 2
2 3
7 4
1 5
5
2 2
4 2
6 2
7 2
0 4
5
3 7
5 4
4 4
9 4
9 9
5
5 4
5 9
5 5
4 3
1 0
5
3 2
1 2
7 2
6 2
5 2
6
7 2
7 9
0 3
8 8
4 4
3 8
6
2 8
2 5
3 5
3 8
2 0
0 2
6
2 3
8 4
2 9
2 2
2 6
4 9
6
2 1
7 6
6 5
...

output:


result: