Submission #1269048
Source Code Expand
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
int gcd(int a, int b) {
if (!b)return a;
return gcd(b, a%b);
}
bool b[1400000][7], c[1400000][7];
int a[100000];
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
int main() {
ll n; int m, q; scanf("%lld%d%d", &n, &m, &q);
int l = m / gcd(m, 7) * 7;
rep(i, q) {
scanf("%d", &a[i]);
for (int j = a[i]; j < 2 * l; j += m) {
c[j / 7][j % 7] = 1;
if (j <= l)b[j / 7][j % 7] = 1;
}
}
queue<P>que;
ll c1 = 0;
rep(i, l / 7)rep(j, 7) {
if (b[i][j])continue;
c1++; que.push(P(i, j));
while (!que.empty()) {
P p = que.front(); que.pop();
rep(k, 4) {
int nx = p.first + dx[k], ny = p.second + dy[k];
if (0 <= nx&&nx < l / 7 && 0 <= ny&&ny < 7 && !b[nx][ny]) {
b[nx][ny] = 1; que.push(P(nx, ny));
}
}
}
}
ll c2 = 0;
rep(i, 2 * l / 7)rep(j, 7) {
if (c[i][j])continue;
c2++; que.push(P(i, j));
while (!que.empty()) {
P p = que.front(); que.pop();
rep(k, 4) {
int nx = p.first + dx[k], ny = p.second + dy[k];
if (0 <= nx&&nx < 2 * l / 7 && 0 <= ny&&ny < 7 && !c[nx][ny]) {
c[nx][ny] = 1; que.push(P(nx, ny));
}
}
}
}
printf("%lld\n", (c2 - c1)*(7*n / l - 1) + c1);
}
Submission Info
Submission Time
2017-05-07 14:58:00+0900
Task
C - Calendar 2
User
autumn_eel
Language
C++14 (GCC 5.4.1)
Score
500
Code Size
1320 Byte
Status
AC
Exec Time
48 ms
Memory
5760 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
ll n; int m, q; scanf("%lld%d%d", &n, &m, &q);
^
./Main.cpp:18:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^
Judge Result
Set Name
Sample
Subtask1
Subtask2
Subtask3
Subtask4
Score / Max Score
0 / 0
100 / 100
90 / 90
200 / 200
110 / 110
Status
Set Name
Test Cases
Sample
sub0_in1.txt, sub0_in2.txt
Subtask1
sub0_in1.txt, sub0_in2.txt, sub1_in1.txt, sub1_in2.txt, sub1_in3.txt, sub1_in4.txt, sub1_in5.txt
Subtask2
sub2_in1.txt
Subtask3
sub2_in1.txt, sub3_in1.txt, sub3_in2.txt
Subtask4
sub0_in1.txt, sub0_in2.txt, sub1_in1.txt, sub1_in2.txt, sub1_in3.txt, sub1_in4.txt, sub1_in5.txt, sub2_in1.txt, sub3_in1.txt, sub3_in2.txt, sub4_in1.txt, sub4_in2.txt
Case Name
Status
Exec Time
Memory
sub0_in1.txt
AC
2 ms
2304 KB
sub0_in2.txt
AC
2 ms
2304 KB
sub1_in1.txt
AC
2 ms
2304 KB
sub1_in2.txt
AC
2 ms
2304 KB
sub1_in3.txt
AC
2 ms
2304 KB
sub1_in4.txt
AC
2 ms
2304 KB
sub1_in5.txt
AC
47 ms
5760 KB
sub2_in1.txt
AC
11 ms
2816 KB
sub3_in1.txt
AC
9 ms
2560 KB
sub3_in2.txt
AC
6 ms
2432 KB
sub4_in1.txt
AC
48 ms
5760 KB
sub4_in2.txt
AC
28 ms
5120 KB