Submission #896179


Source Code Expand

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n, m;
  scanf("%d%d",&n,&m);
  int q;
  scanf("%d",&q);
  vi a(q);
  rep(i,q) {
    scanf("%d",&a[i]);
    --a[i];
  }
  reverse(rng(a));
  vvi p(m);
  rep(i,q) {
    p[a[i]].pb(i);
  }
  vi used(m);
  vi r(n);
  int fr = 0;
  bool ok = true; 
  rep(i,q) {
    if (used[a[i]]) continue;
    int k = 0;
    rep(j,sz(p[a[i]])) {
      if (r[k] > p[a[i]][j]) continue;
      r[k] = p[a[i]][j]; ++k;
      if (k >= n) break;
    }
    if (ok && k == n) {
    } else {
      if (fr == a[i]) {
        ok = false;
      } else {
        puts("No");
        return 0;
      }
    }
    used[a[i]] = 1;
    while (fr < m && used[fr]) ++fr;
  }
  puts("Yes");
  return 0;
}





Submission Info

Submission Time
Task E - LRU Puzzle
User snuke
Language C++14 (GCC 5.4.1)
Score 1200
Code Size 2815 Byte
Status AC
Exec Time 24 ms
Memory 6912 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:66:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&n,&m);
                      ^
./Main.cpp:68:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q);
                 ^
./Main.cpp:71:22: 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 All
Score / Max Score 0 / 0 1200 / 1200
Status
AC × 4
AC × 76
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt, 1_55.txt, 1_56.txt, 1_57.txt, 1_58.txt, 1_59.txt, 1_60.txt, 1_61.txt, 1_62.txt, 1_63.txt, 1_64.txt, 1_65.txt, 1_66.txt, 1_67.txt, 1_68.txt, 1_69.txt, 1_70.txt, 1_71.txt
Case Name Status Exec Time Memory
0_00.txt AC 2 ms 256 KB
0_01.txt AC 2 ms 256 KB
0_02.txt AC 2 ms 256 KB
0_03.txt AC 2 ms 256 KB
1_00.txt AC 2 ms 256 KB
1_01.txt AC 2 ms 256 KB
1_02.txt AC 15 ms 4216 KB
1_03.txt AC 15 ms 4216 KB
1_04.txt AC 15 ms 4216 KB
1_05.txt AC 15 ms 4344 KB
1_06.txt AC 23 ms 6912 KB
1_07.txt AC 24 ms 6912 KB
1_08.txt AC 23 ms 6912 KB
1_09.txt AC 23 ms 6912 KB
1_10.txt AC 20 ms 3584 KB
1_11.txt AC 20 ms 3584 KB
1_12.txt AC 19 ms 3584 KB
1_13.txt AC 19 ms 3584 KB
1_14.txt AC 20 ms 3584 KB
1_15.txt AC 20 ms 3584 KB
1_16.txt AC 20 ms 3584 KB
1_17.txt AC 19 ms 3584 KB
1_18.txt AC 23 ms 5632 KB
1_19.txt AC 23 ms 3840 KB
1_20.txt AC 23 ms 5504 KB
1_21.txt AC 24 ms 6272 KB
1_22.txt AC 24 ms 5888 KB
1_23.txt AC 24 ms 4352 KB
1_24.txt AC 23 ms 6016 KB
1_25.txt AC 23 ms 4352 KB
1_26.txt AC 13 ms 1152 KB
1_27.txt AC 12 ms 1152 KB
1_28.txt AC 15 ms 1280 KB
1_29.txt AC 14 ms 1280 KB
1_30.txt AC 16 ms 3072 KB
1_31.txt AC 16 ms 3200 KB
1_32.txt AC 15 ms 2688 KB
1_33.txt AC 17 ms 3328 KB
1_34.txt AC 20 ms 2560 KB
1_35.txt AC 21 ms 3328 KB
1_36.txt AC 19 ms 2176 KB
1_37.txt AC 21 ms 3072 KB
1_38.txt AC 24 ms 4608 KB
1_39.txt AC 23 ms 5120 KB
1_40.txt AC 23 ms 5248 KB
1_41.txt AC 24 ms 5888 KB
1_42.txt AC 13 ms 1152 KB
1_43.txt AC 13 ms 1280 KB
1_44.txt AC 13 ms 1280 KB
1_45.txt AC 13 ms 1152 KB
1_46.txt AC 15 ms 1664 KB
1_47.txt AC 15 ms 2176 KB
1_48.txt AC 16 ms 2048 KB
1_49.txt AC 17 ms 3584 KB
1_50.txt AC 14 ms 1280 KB
1_51.txt AC 15 ms 1280 KB
1_52.txt AC 16 ms 1536 KB
1_53.txt AC 14 ms 1280 KB
1_54.txt AC 17 ms 3456 KB
1_55.txt AC 14 ms 2176 KB
1_56.txt AC 21 ms 4096 KB
1_57.txt AC 18 ms 3584 KB
1_58.txt AC 12 ms 1152 KB
1_59.txt AC 12 ms 1152 KB
1_60.txt AC 12 ms 1152 KB
1_61.txt AC 12 ms 1152 KB
1_62.txt AC 13 ms 2048 KB
1_63.txt AC 14 ms 3840 KB
1_64.txt AC 13 ms 1920 KB
1_65.txt AC 16 ms 3328 KB
1_66.txt AC 12 ms 1404 KB
1_67.txt AC 12 ms 1404 KB
1_68.txt AC 12 ms 1532 KB
1_69.txt AC 12 ms 1404 KB
1_70.txt AC 15 ms 4092 KB
1_71.txt AC 16 ms 3452 KB