Submission #372504

# Submission time Handle Problem Language Result Execution time Memory
372504 2021-02-28T13:50:14 Z cpp219 Painting Squares (IOI20_squares) C++14
100 / 100
251 ms 656 KB
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 2e3 + 9;
const ll mod = 1e9 + 7;

vector<ll> ans;

void Init(){
    int k = 10;
	for (int i = 0; i < 10; i++) ans.push_back(1);
	int v = (1 << k) - 1;
	vector<bool> kt(1 << k);
	kt[v] = true;
	while ((int)ans.size() < 1000) {
		v = (v << 1) % (1 << k);
		int sign = 0;
		if (kt[v]) {
			v++;
			sign = 1;
		}
		kt[v] = true;
		ans.push_back(sign);
	}
}

vector<ll> paint(ll n){
    if (ans.empty()) Init();
	vector<int> a(n + 1);
	a[n] = 10;
	for (int i = 0; i < n; i++) a[i] = ans[i];
	return a;
}

vector<ll> now;
ll find_location(ll n,vector<ll> c){
    if (ans.empty()) Init();
	for (int i = 0; i < n; i++) {
		now.clear();
		for (int j = 0; j < 10; j++) {
			if (i + j >= n) now.push_back(-1);
			else now.push_back(ans[i + j]);
		}
		if (now == c) return i;
	}
}
/*
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    ll len; cin>>len; paint(len); /// 00000000001000000001
    for (auto i : ans) cout<<i;

}
*/

Compilation message

squares.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
squares.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
squares.cpp: In function 'int find_location(int, std::vector<int>)':
squares.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
   54 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 169 ms 468 KB Output is correct
2 Correct 216 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 548 KB Output is correct
2 Correct 236 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 428 KB Output is correct
2 Correct 170 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 158 ms 548 KB Output is correct
2 Correct 251 ms 556 KB Output is correct