Submission #54344

# Submission time Handle Problem Language Result Execution time Memory
54344 2018-07-03T07:52:54 Z 진화론자(#2049) Flood (IOI07_flood) C++11
22 / 100
137 ms 10228 KB
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;

const int N = 100005;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};

int n, m, x[N], y[N], a[N], b[N], nxt[N][4];
bool col[N], vis[N][2];

vector<int> wait, ans;
priority_queue<pair<int,int> > pq;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d",&x[i],&y[i]);
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		if(x[A] > x[B] || y[A] > y[B]) swap(A, B);
		a[i] = A;
		b[i] = B;
		if(y[A] == y[B]) {
			nxt[A][0] = i;
			nxt[B][2] = i;
		}
		else {
			nxt[A][3] = i;
			nxt[B][1] = i;
		}
		pq.push({x[B], i});
	}
	while(!pq.empty()) {
		int T = pq.top().Y;
		pq.pop();
		if(col[T]) continue;
		int V = a[T], P = (x[a[T]] == x[b[T]] ? 1 : 2);
		for(;;) {
			int D, Z;
			for(int i=0;i<4;i++) {
				D = (P + 3 + i) % 4;
				Z = nxt[V][D];
				if(Z && !col[Z]) break;
			}
			if(vis[Z][D<2]) break;
			vis[Z][D<2] = true;
			wait.push_back(Z);
			V = a[Z] + b[Z] - V;
			P = D;
		}
		for(auto &T : wait) {
			col[T] = true;
		}
		wait.clear();
	}
	for(int i=1;i<=m;i++) {
		if(vis[i][0] && vis[i][1]) ans.push_back(i);
	}
	printf("%d\n",(int)ans.size());
	sort(ans.begin(), ans.end());
	for(auto &T : ans) {
		printf("%d\n",T);
	}
}

Compilation message

flood.cpp: In function 'int main()':
flood.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
flood.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&x[i],&y[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
flood.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&m);
  ~~~~~^~~~~~~~~
flood.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&A,&B);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 496 KB Output is correct
2 Incorrect 2 ms 496 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Incorrect 3 ms 640 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Incorrect 3 ms 700 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1744 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 4576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 4576 KB Output is correct
2 Runtime error 137 ms 9552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 87 ms 9552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 96 ms 10228 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -