Submission #831954

# Submission time Handle Problem Language Result Execution time Memory
831954 2023-08-20T18:33:20 Z DarkMatter Lightning Rod (NOI18_lightningrod) C++14
14 / 100
1470 ms 116344 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int>pi;
typedef pair<ll, ll>pl;
typedef vector<pi>vpi;
typedef vector<pl>vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
const long double PI = acos(-1);
const ll oo = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define read(v) for (auto& it : v) scanf("%d", &it);
#define readL(v) for (auto& it : v) scanf("%lld", &it);
#define print(v) for (auto it : v) printf("%d ", it); puts("");
#define printL(v) for (auto it : v) printf("%lld ", it); puts("");
void solve() {
	int n;
	scanf("%d", &n);
	vpi v(n);
	for (auto& it : v)
		scanf("%d %d", &it.first, &it.second);
	int ans = 0;
	for (int i = 0; i < n; i++)
		if (v[i].second == 1 || ((!i || !v[i - 1].second) && (i == n - 1 || !v[i + 1].second)))
			ans++;
	printf("%d\n", ans);
}
int t = 1;
int main() {
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//#endif
		//scanf("%d", &t);
	while (t--) solve();
}

Compilation message

lightningrod.cpp: In function 'void solve()':
lightningrod.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d %d", &it.first, &it.second);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1351 ms 76164 KB Output is correct
2 Correct 1325 ms 75940 KB Output is correct
3 Correct 1281 ms 73896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1462 ms 78260 KB Output is correct
2 Correct 1470 ms 116344 KB Output is correct
3 Correct 1428 ms 113544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1351 ms 76164 KB Output is correct
2 Correct 1325 ms 75940 KB Output is correct
3 Correct 1281 ms 73896 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -