Submission #895355
Source Code Expand
#define NDEBUG #undef __STRICT_ANSI__ #include <cstdlib> #include <cstdio> #include <tuple> #include <vector> #include <set> #include <algorithm> #include <functional> #include <cstring> #include <cmath> #include <cfloat> #include <cassert> using namespace std; #undef assert #define assert(e) #include <cstdarg> #include <sys/time.h> class XsRandom { unsigned long long a; unsigned long long b; public: inline XsRandom() : a(0x8a5cd789635d2dffULL), b(0x121fd2155c472f96ULL) { } inline XsRandom(const XsRandom & o) : a(o.a), b(o.b) { } inline unsigned long long next64() { unsigned long long c = a ^ (a<<23); a = b; b = c ^ a ^ (c>>18) ^ (a>>5); return b + a; } inline XsRandom(unsigned int seed) : a(0x8a5cd789635d2dffULL), b(0x121fd2155c472f96ULL) { seed = seed * 1234567891 + 521288629; unsigned long long a2 = a; unsigned long long b2 = b; while(seed) { next64(); if(seed & 1) { a2 ^= a; b2 ^= b; } seed >>= 1; } a = a2; b = b2; } inline unsigned int next() { return (unsigned int)next64(); } inline int nextInt(int r) { assert(1<=r); return ((unsigned long long)next() * r)>>32; } }; typedef XsRandom MyRandom; MyRandom g_myRand; double g_startTime; double g_suspendTime = 0; const double g_timeupSecBase = 9.8; double g_timeupSec = g_timeupSecBase; #include <numeric> const char * nextCLineOrWord(int mode) { static char buf[65536]; static int bufLen = sizeof(buf); static int bufPos = sizeof(buf); static bool canReadFlag = true; static bool crFlag = false; static bool enterFlag = false; if(canReadFlag && (enterFlag ? bufLen<=bufPos : (int)sizeof(buf)<=bufPos+bufPos)) { if(0<bufLen-bufPos) { memmove(buf, buf+bufPos, bufLen-bufPos); bufLen -= bufPos; } else { bufLen = 0; } char * result = fgets(buf+bufLen, sizeof(buf)-bufLen, stdin); canReadFlag = (result!=NULL); if(result!=NULL) { int n = strlen(result); enterFlag = (n!=(int)sizeof(buf)-1-bufLen || (1<=bufLen+n && buf[bufLen+n-1]=='\n')); bufLen += n; } bufPos = 0; } if(mode==0) { int pos = bufPos; while(true) { char c = buf[pos]; if(c==32) { buf[pos++] = '\0'; break; } else if(c==10) { if(crFlag) { crFlag = false; if(bufPos==pos) { pos = ++bufPos; continue; } } buf[pos++] = '\0'; break; } else if(c==13) { crFlag = true; buf[pos++] = '\0'; break; } else if(c==0) { break; } ++pos; } const char * ret = buf + bufPos; bufPos = pos; while(true) { char c = buf[bufPos]; if(c==32 || c==10 || c==13) { ++bufPos; } else { break; } } return ret; } else if(mode==1) { int pos = bufPos; while(true) { char c = buf[pos]; if(c==10) { if(crFlag) { crFlag = false; if(bufPos==pos) { pos = ++bufPos; continue; } } buf[pos++] = '\0'; break; } else if(c==13) { crFlag = true; buf[pos++] = '\0'; break; } else if(c==0) { break; } ++pos; } const char * ret = buf + bufPos; bufPos = pos; return ret; } else if(mode==2) { return bufLen<=bufPos ? NULL : buf+bufPos; } assert(false); return NULL; } const char * nextCWord() { return nextCLineOrWord(0); } int nextInt() { return atoi(nextCWord()); } vector<int> nextIntVec(int n) { vector<int> ret; for(int i=0; i<n; ++i) { ret.push_back(nextInt()); } return ret; } void echoln() { fputc('\n', stdout); } void echoln(const char * fmt, ...) { va_list arg; va_start(arg, fmt); vprintf(fmt, arg); va_end(arg); fputc('\n', stdout); } int main() { int N = nextInt(); int M = nextInt(); int Q = nextInt(); vector<int> a = nextIntVec(Q); reverse(a.begin(), a.end()); vector<int> b; vector<int> dic(M+1, -1); { set<int> s; for(int i : a) { if(s.find(i)==s.end()) { s.insert(i); b.push_back(i); } } for(int i=1; i<=M+1; ++i) { if(s.find(i)==s.end()) { b.push_back(i); break; } } int sz = 0; for(int i=1; i<b.size(); ++i) { if(b[i]<b[i-1]) { sz = i; } } b.resize(sz); for(int i=0; i<b.size(); ++i) { dic[b[i]] = i; } } vector<int> q(b.size()+1); q[0] = N; for(int i : a) { int j = dic[i]; if(0<=j) { if(q[j]) { --q[j]; ++q[j+1]; } } } echoln(q[b.size()]==N ? "Yes" : "No"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - LRU Puzzle |
User | colun |
Language | C++14 (GCC 5.4.1) |
Score | 1200 |
Code Size | 4602 Byte |
Status | AC |
Exec Time | 59 ms |
Memory | 6136 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
Status |
|
|
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 | 6 ms | 1144 KB |
1_03.txt | AC | 7 ms | 1144 KB |
1_04.txt | AC | 6 ms | 1144 KB |
1_05.txt | AC | 7 ms | 1144 KB |
1_06.txt | AC | 46 ms | 6136 KB |
1_07.txt | AC | 48 ms | 6136 KB |
1_08.txt | AC | 47 ms | 6136 KB |
1_09.txt | AC | 47 ms | 6136 KB |
1_10.txt | AC | 29 ms | 3448 KB |
1_11.txt | AC | 29 ms | 3448 KB |
1_12.txt | AC | 28 ms | 3448 KB |
1_13.txt | AC | 29 ms | 3448 KB |
1_14.txt | AC | 29 ms | 3448 KB |
1_15.txt | AC | 30 ms | 3448 KB |
1_16.txt | AC | 29 ms | 3448 KB |
1_17.txt | AC | 29 ms | 3448 KB |
1_18.txt | AC | 39 ms | 5368 KB |
1_19.txt | AC | 40 ms | 3704 KB |
1_20.txt | AC | 39 ms | 5240 KB |
1_21.txt | AC | 59 ms | 6008 KB |
1_22.txt | AC | 39 ms | 5240 KB |
1_23.txt | AC | 36 ms | 3576 KB |
1_24.txt | AC | 36 ms | 5496 KB |
1_25.txt | AC | 39 ms | 3960 KB |
1_26.txt | AC | 11 ms | 892 KB |
1_27.txt | AC | 9 ms | 892 KB |
1_28.txt | AC | 14 ms | 892 KB |
1_29.txt | AC | 14 ms | 892 KB |
1_30.txt | AC | 12 ms | 1144 KB |
1_31.txt | AC | 13 ms | 1144 KB |
1_32.txt | AC | 12 ms | 892 KB |
1_33.txt | AC | 13 ms | 1144 KB |
1_34.txt | AC | 23 ms | 2296 KB |
1_35.txt | AC | 29 ms | 3192 KB |
1_36.txt | AC | 19 ms | 1912 KB |
1_37.txt | AC | 34 ms | 2936 KB |
1_38.txt | AC | 40 ms | 4216 KB |
1_39.txt | AC | 38 ms | 4856 KB |
1_40.txt | AC | 29 ms | 4216 KB |
1_41.txt | AC | 47 ms | 5240 KB |
1_42.txt | AC | 10 ms | 892 KB |
1_43.txt | AC | 10 ms | 892 KB |
1_44.txt | AC | 11 ms | 892 KB |
1_45.txt | AC | 10 ms | 892 KB |
1_46.txt | AC | 13 ms | 892 KB |
1_47.txt | AC | 13 ms | 892 KB |
1_48.txt | AC | 14 ms | 1016 KB |
1_49.txt | AC | 13 ms | 1144 KB |
1_50.txt | AC | 13 ms | 892 KB |
1_51.txt | AC | 11 ms | 892 KB |
1_52.txt | AC | 15 ms | 1144 KB |
1_53.txt | AC | 14 ms | 892 KB |
1_54.txt | AC | 14 ms | 1272 KB |
1_55.txt | AC | 11 ms | 892 KB |
1_56.txt | AC | 19 ms | 2040 KB |
1_57.txt | AC | 16 ms | 1272 KB |
1_58.txt | AC | 8 ms | 892 KB |
1_59.txt | AC | 9 ms | 892 KB |
1_60.txt | AC | 8 ms | 892 KB |
1_61.txt | AC | 8 ms | 892 KB |
1_62.txt | AC | 10 ms | 892 KB |
1_63.txt | AC | 7 ms | 1144 KB |
1_64.txt | AC | 7 ms | 892 KB |
1_65.txt | AC | 11 ms | 1144 KB |
1_66.txt | AC | 7 ms | 1020 KB |
1_67.txt | AC | 7 ms | 892 KB |
1_68.txt | AC | 7 ms | 892 KB |
1_69.txt | AC | 8 ms | 892 KB |
1_70.txt | AC | 7 ms | 1144 KB |
1_71.txt | AC | 9 ms | 1144 KB |