Submission #476927

# Submission time Handle Problem Language Result Execution time Memory
476927 2021-09-29T07:57:02 Z AdamGS Teoretičar (COCI18_teoreticar) C++14
0 / 130
836 ms 71008 KB
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7;
int ans[LIM];
bool ok(vector<pair<pair<int,int>,int>>V) {
	vector<int>l, r;
	for(auto i : V) {
		l.pb(i.st.st);
		r.pb(i.st.nd);
	}
	sort(all(l));
	sort(all(r));
	rep(i, l.size()-1) if(l[i]==l[i+1]) return false;
	rep(i, r.size()-1) if(r[i]==r[i+1]) return false;
	return true;
}
void dc(vector<pair<pair<int,int>,int>>V, int x) {
	if(V.size()==0 || ok(V)) return;
	vector<pair<pair<int,int>,int>>V1, V2;
	rep(i, V.size()) {
		if(i%2==0) V1.pb(V[i]);
		else V2.pb(V[i]);
	}
	for(auto i : V2) ans[i.nd]+=x;
	dc(V1, 2*x);
	dc(V2, 2*x);
}
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int l, r, m;
	cin >> l >> r >> m;
	vector<pair<pair<int,int>,int>>V;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		V.pb({{a, b}, i});
	}
	sort(all(V));
	dc(V, 1);
	int ma=0;
	rep(i, m) ma=max(ma, ans[i]);
	cout << ma+1 << '\n';
	rep(i, m) cout << ans[i]+1 << '\n';
}

Compilation message

teoreticar.cpp: In function 'bool ok(std::vector<std::pair<std::pair<long long int, long long int>, long long int> >)':
teoreticar.cpp:5:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
teoreticar.cpp:20:2: note: in expansion of macro 'rep'
   20 |  rep(i, l.size()-1) if(l[i]==l[i+1]) return false;
      |  ^~~
teoreticar.cpp:5:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
teoreticar.cpp:21:2: note: in expansion of macro 'rep'
   21 |  rep(i, r.size()-1) if(r[i]==r[i+1]) return false;
      |  ^~~
teoreticar.cpp: In function 'void dc(std::vector<std::pair<std::pair<long long int, long long int>, long long int> >, long long int)':
teoreticar.cpp:5:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
teoreticar.cpp:27:2: note: in expansion of macro 'rep'
   27 |  rep(i, V.size()) {
      |  ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1116 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1116 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 602 ms 54436 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 558 ms 54420 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 836 ms 67756 KB Output is correct
2 Incorrect 800 ms 71008 KB too many colors
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 815 ms 69300 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 657 ms 57880 KB too many colors
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 622 ms 57724 KB too many colors
2 Halted 0 ms 0 KB -