Submission #126517

# Submission time Handle Problem Language Result Execution time Memory
126517 2019-07-08T02:54:02 Z wilwxk Highway design (CEOI12_highway) C++14
0 / 100
11 ms 4572 KB
#include <bits/stdc++.h>
#include "office.h"
using namespace std;

const int MAXN=1e5+5;
vector<int> bloco[MAXN], bons;
int ok[MAXN];
int n, nn;

bool checa() {
	if(bons.size()<2) return 0;
	int cara=bons[0];
	while(bons.size()%3) bons.push_back(bons[bons.size()%3-1]);
	for(int i=2; i<bons.size(); i+=3) {
		int cur=bons[i];
		int ant=bons[i-1];
		int ant2=bons[i-2];
		// printf("sdbaybd %d .. %d\n", i, cur);
		if(!isOnLine(bloco[ant2][0], bloco[ant][0], bloco[cur][0])) {
			if(!isOnLine(bloco[ant2][0], bloco[ant2][1], bloco[ant][0])) Answer(bloco[ant2][0], bloco[ant2][1], bloco[ant][0], bloco[ant][1]);
			else Answer(bloco[cur][0], bloco[cur][1], bloco[ant][0], bloco[ant][1]);
			return 1;
		}
	}
	return 0;
}

int main() {
	n=GetN();
	for(int i=1; i<=n; i++) bloco[(i-1)/3+1].push_back(i);
	nn=(n-1)/3+1;
	for(int i=1; i<=nn; i++) if(bloco[i].size()==3) ok[i]=isOnLine(bloco[i][0], bloco[i][1], bloco[i][2]);

	for(int i=1; i<=nn; i++) if(ok[i]) bons.push_back(i);
	if(checa()) return 0;

	// printf("sdabsdah\n");


	if(bons.size()) {
		int cara=bons[0];
		vector<int> resp;
		for(int i=1; i<=nn; i++) {
			if(!ok[i]) {
				for(auto cur : bloco[i]) {
					if(!isOnLine(bloco[cara][0], bloco[cara][1], cur)) resp.push_back(cur);
				}
				if(resp.size()>=2) {
					Answer(bloco[cara][0], bloco[cara][1], resp[0], resp[1]);
					return 0;
				}
			}
		}
	}
	else {
		int pronto=0;
		for(int i=0; i<3; i++) {
			bool a=isOnLine(bloco[0][0], bloco[0][1], bloco[1][i]);
			bool b=isOnLine(bloco[0][1], bloco[0][2], bloco[1][i]);
			bool c=isOnLine(bloco[0][0], bloco[0][2], bloco[1][i]);
			if(a||b||c) {
				if(a) swap(bloco[0][2], bloco[1][i]);
				else if(b) swap(bloco[0][0], bloco[1][i]);
				else swap(bloco[0][1], bloco[1][i]);
				pronto=i; break;
			}
		}
		if(pronto==2) {
			Answer(bloco[0][0], bloco[0][1], bloco[1][0], bloco[1][1]);
			return 0;
		}
		else {
			vector<int> resp;
			for(int i=0; i<3; i++) if(!isOnLine(bloco[0][0], bloco[0][1], bloco[1][i])) resp.push_back(i);
			Answer(bloco[0][0], bloco[0][1], resp[0], resp[1]);
		}
	}
}

Compilation message

highway.cpp: In function 'bool checa()':
highway.cpp:14:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=2; i<bons.size(); i+=3) {
               ~^~~~~~~~~~~~
highway.cpp:12:6: warning: unused variable 'cara' [-Wunused-variable]
  int cara=bons[0];
      ^~~~
office.c: In function 'int isOnLine(int, int, int)':
office.c:85:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     _Fin(0, "Protocol error");
                             ^
office.c:88:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     _Fin(0, "Protocol error");
                             ^
office.c:92:37: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     _Fin(false, "Too many questions");
                                     ^
office.c:83:7: warning: unused variable 'i' [-Wunused-variable]
   int i;
       ^
office.c: In function 'void Answer(int, int, int, int)':
office.c:123:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     _Fin(0, "Protocol error");
                             ^
office.c:128:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
       if( (-_Apa[na1]==_N-3) && (na2!=na1) && (nb2!=na1) ||
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
office.c:130:30: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
          _Fin(true, "Correct");
                              ^
office.c:132:36: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
          _Fin(false, "Wrong answer");
                                    ^
office.c:134:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
       if( (-_Apa[na2]==_N-3) && (na1!=na2) && (nb1!=na2) ||
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
office.c:136:30: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
          _Fin(true, "Correct");
                              ^
office.c:138:36: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
          _Fin(false, "Wrong answer");
                                    ^
office.c:140:33: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
       _Fin(false, "Wrong answer");
                                 ^
office.c:142:23: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   _Fin(true, "Correct");
                       ^
office.c:120:27: warning: unused variable 'pont' [-Wunused-variable]
   int na1, nb1, na2, nb2, pont;
                           ^~~~
office.c: In function 'void _doInit()':
office.c:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &_N);
     ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2680 KB Hacked
2 Incorrect 4 ms 2680 KB Hacked
3 Incorrect 4 ms 2680 KB Hacked
4 Incorrect 4 ms 2680 KB Hacked
5 Incorrect 4 ms 2680 KB Hacked
6 Incorrect 4 ms 2680 KB Hacked
7 Incorrect 4 ms 2680 KB Hacked
8 Incorrect 4 ms 2808 KB Hacked
9 Incorrect 4 ms 2680 KB Hacked
10 Incorrect 4 ms 2680 KB Hacked
11 Incorrect 4 ms 2680 KB Hacked
12 Incorrect 4 ms 2680 KB Hacked
13 Incorrect 5 ms 2808 KB Hacked
14 Incorrect 4 ms 2684 KB Hacked
15 Incorrect 5 ms 2812 KB Hacked
16 Incorrect 5 ms 2680 KB Hacked
17 Incorrect 5 ms 2680 KB Hacked
18 Incorrect 4 ms 2680 KB Hacked
19 Incorrect 7 ms 3196 KB Hacked
20 Incorrect 7 ms 3320 KB Hacked
21 Incorrect 7 ms 3448 KB Hacked
22 Incorrect 8 ms 3832 KB Hacked
23 Incorrect 9 ms 3960 KB Hacked
24 Incorrect 10 ms 4216 KB Hacked
25 Incorrect 11 ms 4572 KB Hacked