Submission #836155
Source Code Expand
Copy
/* */ //#pragma comment(linker, "/STACK:16777216") #define _CRT_SECURE_NO_WARNINGS #include <fstream> #include <iostream> #include <string> #include <complex> #include <math.h> #include <set> #include <vector> #include <map> #include <queue> #include <stdio.h> #include <stack> #include <algorithm> #include <list> #include <ctime> #include <memory.h> #include <assert.h> #define y0 sdkfaslhagaklsldk #define y1 aasdfasdfasdf #define yn askfhwqriuperikldjk #define j1 assdgsdgasghsf #define tm sdfjahlfasfh #define lr asgasgash #define norm asdfasdgasdgsd #define eps 1e-9 #define M_PI 3.141592653589793 #define bs 1000000007 #define bsize 350 using namespace std; const int INF = 1e9; const int N = 200000; int ai = -1; int aj = -1; string st; int bal[N][27], best_bal[N], best_pos[N]; int main(){ //freopen("fabro.in","r",stdin); //freopen("fabro.out","w",stdout); //freopen("F:/in.txt", "r", stdin); //freopen("F:/output.txt", "w", stdout); ios_base::sync_with_stdio(0); //cin.tie(0); for (int i = 0; i < 26; i++) best_bal[i] = 1e9; cin >> st; for (int i = 0; i < st.size(); i++) { for (int j = 0; j < 26; j++) { bal[i+1][j] = bal[i][j]-1; } bal[i + 1][st[i] - 'a'] += 2; if (i >= 1) { for (int j = 0; j < 26; j++) { if (bal[i - 1][j]<best_bal[j]) { best_bal[j] = bal[i - 1][j]; best_pos[j] = i - 1; } } } for (int j = 0; j < 26; j++) { if (bal[i+1][j]>best_bal[j]) { ai = best_pos[j]+1; aj = i + 1; break; } } } cout << ai << " " << aj << endl; cin.get(); cin.get(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Unbalanced |
User | LeBron |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1682 Byte |
Status | AC |
Exec Time | 38 ms |
Memory | 11088 KB |
Compile Error
./Main.cpp:33:0: warning: "M_PI" redefined #define M_PI 3.141592653589793 ^ In file included from /usr/include/c++/5/cmath:44:0, from /usr/include/c++/5/complex:44, from ./Main.cpp:10: /usr/include/math.h:372:0: note: this is the location of the previous definition # define M_PI 3.14159265358979323846 /* pi */ ^
Judge Result
Set Name | Sample | Sub1 | Sub2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 200 / 200 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_01, 0_02 |
Sub1 | 0_01, 0_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14 |
Sub2 | 0_01, 0_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09, 1_10, 1_11, 1_12, 1_13, 1_14, 2_15, 2_16, 2_17, 2_18, 2_19, 2_20, 2_21, 2_22, 2_23, 2_24 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_01 | AC | 4 ms | 256 KB |
0_02 | AC | 4 ms | 256 KB |
1_03 | AC | 4 ms | 256 KB |
1_04 | AC | 4 ms | 256 KB |
1_05 | AC | 4 ms | 256 KB |
1_06 | AC | 4 ms | 256 KB |
1_07 | AC | 4 ms | 256 KB |
1_08 | AC | 4 ms | 256 KB |
1_09 | AC | 4 ms | 256 KB |
1_10 | AC | 4 ms | 256 KB |
1_11 | AC | 4 ms | 256 KB |
1_12 | AC | 4 ms | 256 KB |
1_13 | AC | 4 ms | 256 KB |
1_14 | AC | 4 ms | 256 KB |
2_15 | AC | 34 ms | 11088 KB |
2_16 | AC | 34 ms | 11088 KB |
2_17 | AC | 35 ms | 11088 KB |
2_18 | AC | 37 ms | 11088 KB |
2_19 | AC | 37 ms | 11088 KB |
2_20 | AC | 37 ms | 11088 KB |
2_21 | AC | 38 ms | 11088 KB |
2_22 | AC | 33 ms | 11088 KB |
2_23 | AC | 36 ms | 11088 KB |
2_24 | AC | 36 ms | 11088 KB |