Submission #128043

# Submission time Handle Problem Language Result Execution time Memory
128043 2019-07-10T10:56:34 Z claudy Street Lamps (APIO19_street_lamps) C++14
20 / 100
246 ms 31752 KB
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# define sim template < class c
# define ris return * this
# define dor > debug & operator <<
# define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int n,q;
string s;
int f[1 << 19],x[1 << 19],ans[1 << 19];
vector<int>vec[1 << 19];

int32_t main(){_
	//freopen("input","r",stdin);
	cin >> n >> q;
	cin >> s;
	for(int i = 1;i <= n;i++)
	{
		if(s[i - 1] == '0') f[i] = 0;
		else f[i] = 1;
		vec[i].pb(0);
	}
	for(int i = 1;i <= q;i++)
	{
		string op;
		cin >> op;
		if(op[0] == 't')
		{
			cin >> x[i];
			if(f[x[i]] == 1) ans[x[i]] += i - vec[x[i]].back();
			f[x[i]] = !f[x[i]];
			vec[x[i]].pb(i);
		}
		else
		{
			int l;
			int r;
			cin >> l >> r;
			r--;
			cout << ans[l] + (f[l] ? i - vec[l].back() : 0) << '\n';
			
		}
	}
	return 0;
}









Compilation message

street_lamps.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 # pragma GCC optimization ("unroll-loops")
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 12664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 96 ms 15740 KB Output is correct
2 Correct 102 ms 19320 KB Output is correct
3 Correct 116 ms 19960 KB Output is correct
4 Correct 220 ms 31752 KB Output is correct
5 Correct 224 ms 31228 KB Output is correct
6 Correct 246 ms 31156 KB Output is correct
7 Correct 176 ms 30080 KB Output is correct
8 Correct 226 ms 31472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 12664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 12792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 12664 KB Output isn't correct
2 Halted 0 ms 0 KB -