NJPC2017

Submission #1088510

Source codeソースコード

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll h, w;
  int n;
  scanf("%lld %lld %d", &h, &w, &n);
  vi y(n), x(n);
  rep (i, n) {
    scanf("%d %d", &y[i], &x[i]);
    y[i] *= 2;
    x[i] *= 2;
  }
  set<pii> x_edges;
  rep (i, n) {
    if (x[i] != 2) {
      x_edges.insert(make_pair(x[i]-1, y[i]));
    }
    if (x[i] != w*2) {
      x_edges.insert(make_pair(x[i]+1, y[i]));
    }
    if (y[i] != 2) {
      x_edges.insert(make_pair(x[i], y[i]-1));
    }
    if (y[i] != h*2) {
      x_edges.insert(make_pair(x[i], y[i]+1));
    }
  }
  printf("%lld\n", h*(w-1) + (h-1)*w - (ll)x_edges.size());
  return 0;
}

Submission

Task問題 B - 格子グラフ
User nameユーザ名 mu
Created time投稿日時
Language言語 C++14 (Clang 3.8.0)
Status状態 AC
Score得点 300
Source lengthソースコード長 1508 Byte
File nameファイル名
Exec time実行時間 4 ms
Memory usageメモリ使用量 512 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_sample_00,00_sample_01,00_sample_02
All 300 / 300 00_sample_00,00_sample_01,00_sample_02,in01,in02,in03,in04,in05,in06,in07,in08,in09,in10,in11,in12,in13,in14,in15,in16,in17,in18,in19,in20,in21,in22,in23,in24,in25,in26,in27,in28

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_00 AC 3 ms 256 KB
00_sample_01 AC 3 ms 256 KB
00_sample_02 AC 3 ms 256 KB
in01 AC 3 ms 256 KB
in02 AC 3 ms 256 KB
in03 AC 3 ms 256 KB
in04 AC 3 ms 256 KB
in05 AC 3 ms 256 KB
in06 AC 3 ms 256 KB
in07 AC 3 ms 256 KB
in08 AC 3 ms 256 KB
in09 AC 3 ms 256 KB
in10 AC 3 ms 256 KB
in11 AC 3 ms 256 KB
in12 AC 3 ms 256 KB
in13 AC 3 ms 256 KB
in14 AC 3 ms 256 KB
in15 AC 3 ms 256 KB
in16 AC 3 ms 256 KB
in17 AC 3 ms 256 KB
in18 AC 3 ms 256 KB
in19 AC 3 ms 256 KB
in20 AC 3 ms 256 KB
in21 AC 3 ms 256 KB
in22 AC 4 ms 512 KB
in23 AC 4 ms 384 KB
in24 AC 3 ms 256 KB
in25 AC 4 ms 512 KB
in26 AC 3 ms 256 KB
in27 AC 3 ms 256 KB
in28 AC 3 ms 256 KB